From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id cBgHJa7cKGTrQQAASxT56A (envelope-from ) for ; Sun, 02 Apr 2023 03:38:54 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id uFMWJK7cKGRdRgEAG6o9tA (envelope-from ) for ; Sun, 02 Apr 2023 03:38:54 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 30119D6CB for ; Sun, 2 Apr 2023 03:38:53 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pilsV-0006hr-MX; Sat, 01 Apr 2023 20:47:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pilsR-0006hd-QN for emacs-orgmode@gnu.org; Sat, 01 Apr 2023 20:47:24 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pilsP-0000KA-7k for emacs-orgmode@gnu.org; Sat, 01 Apr 2023 20:47:23 -0400 Received: by mail-pl1-x630.google.com with SMTP id le6so24878067plb.12 for ; Sat, 01 Apr 2023 17:47:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680396438; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=/t5frW2VBicLbUJb7vCvc5SVt8WOcQnUeTIz4xc21vU=; b=fMM1EEV7j2gPeP/AKs5DAz6K9yTChkD5uynwmDKvWBPBrZo7LmDfOfbD+ekw6Kvxu2 xgFtM4L9p9fzZ535RZYIqqJ2vL7wAhbS58RoyhtyTJArcxHatg+3EQWmZB6FUX4IjieD M3xHHUhE/1gIWzvYofiSsDqprajSm3854ZpUKwYj+Gdb2/X8WUFETWEEqjPdPQMCIerx GM9/SBimwi7bSZlG/JLMEycmRQuD4JLIagKDbjuxfUhtgM9IRXftMtycVJ84WS7CRKhv y/tlHLmYBc1HQXojwZnSnKm5lK3OLyTB8D8N+EWUUL142am/YlFvpFeri9intUzEKFgW vOPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680396438; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/t5frW2VBicLbUJb7vCvc5SVt8WOcQnUeTIz4xc21vU=; b=zL9MVs/Q9uj9ZgfyAlSBI8Dq3Kc/bzAeIbBnewwSkUQHrGnM7lfdWEXZhE77IvFvNA BS+YDfd06gC1GQhCb+o6uZ3h+r/EOHj73hf/7eUf4C8dcSVAjT5UN0WsSDdy7k8RPY6c oTkwWgM2VksEFUQjLACpi6Ryg6o/mqsotiJO3TkvkaOTse4d+bozkHpp0JFx/j3vx9oi S331jKeXPrKshwirx53nSzodxKYZrAOWOzBWOyu3UkAQcLOrwABLCGUrR12NgfwIupvJ nfuSu+2ERZRZWdEtXCD84pZZ3wLoqpxKBsTT/hmHgb61CgAgv0XQdjxRP9w6oiqK1+Lr 3fDg== X-Gm-Message-State: AAQBX9dxVqEc/fmlGSkW+H99SaasjC2mXe/ldKHDKwrg3su5J6EteyP8 nfMIVl3oycXAMMzvwtKDxC6YII2gEGY= X-Google-Smtp-Source: AKy350bWKWedpmmDVCX+lMS8uX17MCuG2fX1aPYyA6PvGzu9QJO0c/602VtrddxL7MOCku+imiPzTA== X-Received: by 2002:a17:90b:38d2:b0:234:dc4:2006 with SMTP id nn18-20020a17090b38d200b002340dc42006mr37686205pjb.4.1680396438249; Sat, 01 Apr 2023 17:47:18 -0700 (PDT) Received: from localhost (157-131-78-143.fiber.dynamic.sonic.net. [157.131.78.143]) by smtp.gmail.com with ESMTPSA id bb24-20020a17090b009800b00230dc295651sm3687123pjb.8.2023.04.01.17.47.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 17:47:17 -0700 (PDT) From: Jack Kamm To: Ihor Radchenko Cc: emacs-orgmode@gnu.org, mail@nicolasgoaziou.fr Subject: Re: [RFC] ox-icalendar: Unscheduled tasks & repeating tasks In-Reply-To: <87tty0f1i5.fsf@localhost> References: <874jq75okg.fsf@gmail.com> <87o7oetneo.fsf@localhost> <87r0t5jwgy.fsf@gmail.com> <87v8ih9ihw.fsf@localhost> <87o7o8kji5.fsf@gmail.com> <87fs9kajx7.fsf@localhost> <87jzywk1fs.fsf@gmail.com> <87tty0f1i5.fsf@localhost> Date: Sat, 01 Apr 2023 17:47:16 -0700 Message-ID: <87h6tzjejv.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=jackkamm@gmail.com; helo=mail-pl1-x630.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1680399533; a=rsa-sha256; cv=none; b=TqGO5ej4wdIdKqVdx2mA/TniagmD/vosERn7+h/m8+3vHrSobji4/9kUe+AXI0LG3uO65C 0Fk2A26HQ52PwS4yPSmt2qV57kItJveSEmgdbu7PDS6XGRaEe6OdYeLEY4DBd+l1tTe51K 3Ewto4SA1m1968qtyrm8X5hhedRx9/4ubB1/Wm66CJF/Qr8ODEY0XPX0CpTrAGFXygAIXj 0G69i4j+A4QUYtk+la/WYPUFeFPNZoo2fNEJLiKJTV1m48UMQ3hhOSHmCOvmCignA+pDso uf7bxV9ZMh8T7rn/NUhsQHgeZhlAZAYxJPbPBuqFwTu/bKNM91Y2gVPXIPmPUg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20210112 header.b=fMM1EEV7; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1680399533; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=UxifE+aKmjGJFrh+Ysvdflz4My/hVxbmNjElrbFYb5c=; b=m9pxjXlI1YUITkqADZgEZLEWwEVoxJtkFojMDrxQK80DZZWDTwESb2T7p/4UrxQ4fkZBq9 qF9LOTaUxZQdX0pAXRa9kvOv+SzC5XG/CqCy3w4wCaSTCRlst7S5lYWcVz8Fvli6F0ni74 Tv1p+GfpcasDanIorats2whtulopVfBTTah1CRKBCNtH+lmZEqOpMZgssnS3jGgOFDVwL+ Vkb+IFdKQ7kjt3Zo25jlffh1wqs8R4IrfVOUMWvGZBb211MtTDFsmqnmz55gTTihpIULuJ ZFh0s1qwFKKTyIM27LFAepx27uEkymup2Wvq+dtYGbupu1EeKIunpr1hSf4FPQ== Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20210112 header.b=fMM1EEV7; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Scanner: scn0.migadu.com X-Migadu-Spam-Score: -1.43 X-Spam-Score: -1.43 X-Migadu-Queue-Id: 30119D6CB X-TUID: 9ZKHLLeY9Lae --=-=-= Content-Type: text/plain Ihor Radchenko writes: > So, we should probably override `org-export-coding-system', even when it > is set. iCalendar demands UTF8 anyway. Also, ox-icalendar already sets ":ascii-charset utf-8" in the ext-plist during export. > We likely want (according to 34.10.1 Basic Concepts of Coding Systems): I attach a new patch, which takes the approach of converting to utf-8-dos in `org-icalendar-after-save-hook', instead of converting newlines in `org-icalendar-fold-string'. I think this way is simpler, and should be more robust across locales. Note, this means the string returned by `org-export-as' won't contain CRLF. Instead, the newlines are converted during post-process. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-ox-icalendar-Use-consistent-CRLF-line-endings.patch >From 04761429f82bfd2aee63f4978afec3449abaa37d Mon Sep 17 00:00:00 2001 From: Jack Kamm Date: Sat, 1 Apr 2023 16:53:35 -0700 Subject: [PATCH] ox-icalendar: Use consistent CRLF line endings Fixes issue where the ox-icalendar export uses an inconsistent mix of dos and unix style line endings. * lisp/ox-icalendar.el (org-icalendar-fold-string): No longer converts to CRLF, instead delegating that to `org-icalendar--convert-eol'. (org-icalendar--convert-eol): New function to convert EOL to CRLF. It runs early in `org-icalendar-after-save-hook'. * testing/lisp/test-ox-icalendar.el: New file for unit tests of ox-icalendar. Add an initial test for CRLF line endings. See also: https://list.orgmode.org/87o7oetneo.fsf@localhost/T/#m3e3eb80f9fc51ba75854b33ebfe9ecdefa2ded24 https://list.orgmode.org/orgmode/87ilgljv6i.fsf@localhost/ --- etc/ORG-NEWS | 12 +++++++++ lisp/ox-icalendar.el | 14 +++++++--- testing/lisp/test-ox-icalendar.el | 44 +++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 testing/lisp/test-ox-icalendar.el diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index ac233a986..9f7d01707 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -23,6 +23,18 @@ If you still want to use python-mode with ob-python, you might consider [[https://gitlab.com/jackkamm/ob-python-mode-mode][ob-python-mode-mode]], where the code to support python-mode has been ported to. +*** =ox-icalendar.el= line ending fix may affect downstream packages + +iCalendar export now uses dos-style CRLF ("\r\n") line endings +throughout, as required by the iCalendar specification (RFC 5545). +Previously, the export used an inconsistent mix of dos and unix line +endings. + +This might cause errors in external packages that parse output from +ox-icalendar. In particular, older versions of org-caldav may +encounter issues, and users are advised to update to the most recent +version of org-caldav. See [[https://github.com/dengste/org-caldav/commit/618bf4cdc9be140ca1993901d017b7f18297f1b8][this org-caldav commit]] for more information. + ** New and changed options *** New ~org-cite-natbib-export-bibliography~ option defining fallback bibliography style diff --git a/lisp/ox-icalendar.el b/lisp/ox-icalendar.el index 81a77a770..7f675b5d0 100644 --- a/lisp/ox-icalendar.el +++ b/lisp/ox-icalendar.el @@ -540,12 +540,20 @@ (defun org-icalendar-fold-string (s) ;; line, real contents must be split at 74 chars. (while (< (setq chunk-end (+ chunk-start 74)) len) (setq folded-line - (concat folded-line "\r\n " + (concat folded-line "\n " (substring line chunk-start chunk-end)) chunk-start chunk-end)) - (concat folded-line "\r\n " (substring line chunk-start)))))) - (org-split-string s "\n") "\r\n"))) + (concat folded-line "\n " (substring line chunk-start)))))) + (org-split-string s "\n") "\n"))) +(defun org-icalendar--convert-eol (f) + "Convert line endings to CRLF as per RFC 5545." + (with-temp-buffer + (insert-file-contents f) + (let ((coding-system-for-write 'utf-8-dos)) + (write-region nil nil f)))) + +(add-hook 'org-icalendar-after-save-hook #'org-icalendar--convert-eol -90) ;;; Filters diff --git a/testing/lisp/test-ox-icalendar.el b/testing/lisp/test-ox-icalendar.el new file mode 100644 index 000000000..bfc756d51 --- /dev/null +++ b/testing/lisp/test-ox-icalendar.el @@ -0,0 +1,44 @@ +;;; test-ox-icalendar.el --- tests for ox-icalendar.el -*- lexical-binding: t; -*- + +;; Copyright (C) 2023 Jack Kamm + +;; Author: Jack Kamm + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: + +;; Tests checking validity of Org iCalendar export output. + +;;; Code: + +(require 'ox-icalendar) + +(ert-deftest test-ox-icalendar/crlf-endings () + "Test every line of iCalendar export has CRLF ending." + (let ((tmp-ics (org-test-with-temp-text-in-file + "* Test event +:PROPERTIES: +:ID: b17d8f92-1beb-442e-be4d-d2060fa3c7ff +:END: +<2023-03-30 Thu>" + (expand-file-name (org-icalendar-export-to-ics))))) + (unwind-protect + (with-temp-buffer + (insert-file-contents tmp-ics) + (should (eql 1 (coding-system-eol-type last-coding-system-used)))) + (when (file-exists-p tmp-ics) (delete-file tmp-ics))))) + +(provide 'test-ox-icalendar) +;;; test-ox-icalendar.el ends here -- 2.39.2 --=-=-=--