From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.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 WFwyI8mgKWQJagEASxT56A (envelope-from ) for ; Sun, 02 Apr 2023 17:35:37 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id 8IQ1I8mgKWQu9gAA9RJhRA (envelope-from ) for ; Sun, 02 Apr 2023 17:35:37 +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 1F183251F8 for ; Sun, 2 Apr 2023 17:35:36 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pizjV-0006it-V2; Sun, 02 Apr 2023 11:35:05 -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 1pizjU-0006ie-Tq for emacs-orgmode@gnu.org; Sun, 02 Apr 2023 11:35:05 -0400 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pizjS-0002zv-TX for emacs-orgmode@gnu.org; Sun, 02 Apr 2023 11:35:04 -0400 Received: by mail-pj1-x102c.google.com with SMTP id h12-20020a17090aea8c00b0023d1311fab3so28107107pjz.1 for ; Sun, 02 Apr 2023 08:35:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680449701; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=TSUiMaMxotGvJDbBXHtRCNMeliNwj8rpHM+kKQVzjPk=; b=GAplw/JzfmWVugxngvit/chs7/DwXYiQNGndcM4F/YPFtAx6sErAzo3WBSqncoDBxw fU5FHwQlsO8CezEwlIyeN56i/d77p9lM67jhpxh3ClGIrqGF2rBXCpQDkbdBEAo0n06R oBMBKqSqGFJ+CXKfPStTCuHhyBYzJ+MVPwvEu+0ZdCfl2bPIPdoCcjzLMMdYDRBf4PH4 Hoe6+i/akM2BW2aIFud1kYb+IhokSDKPDkfXejh8s0dKtwAS+Po7Zy6R/VGXzYigoOL5 DYkPZ5acC4e/tNHB7pCGtWRttime+ttlcRrHr7DKtq8S02QKAkR9y/DeMAWHSm4jKeDh JI6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680449701; 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=TSUiMaMxotGvJDbBXHtRCNMeliNwj8rpHM+kKQVzjPk=; b=5At8b0wRoq8w0wG5bVwvpw6PUDcypfjQ/BEcmTaOwETVhrC8YTdr4zHaAmHzuLgblX 6//EseQJW3IfddUXW8hGS9EFP17TqrIKZ9DdCOjctfO6+UuvZXO+w5JO1fQo9ZMKlRnT BX03tPXGp1JJYijcOLCgDQiTK4EZUCCBK4rjfH3bRIDDgF5enHi+lSMV8SzPeZY17R08 HbnXnwRFruvHKhqkE9ibb1c82Qv77oe5r1oHwHw0xPQwJkPaZ1H31u2Fi0ZNw7ezsPx5 QGunqXQyS9jQ4Cydg4yGPnDUNCedlkn03Z2HmYGv3AG80Q40GKfZ0P1hpMEw3p9KgJF4 yQ6A== X-Gm-Message-State: AAQBX9d46EkgWMobmrkyKUHctYyUv5E1twKthxVVNXUFIIglAZj02jS1 eK+nH1ctBePcIsVy84KZw7Q= X-Google-Smtp-Source: AKy350Z3MNr+q5R/5LQQzW8TTDPyi6tei5Q3BtXbRBbiv8GLYtfNqD229PxTRjII1Lndr9YKgVbDaQ== X-Received: by 2002:a17:903:41c4:b0:1a2:a904:c42e with SMTP id u4-20020a17090341c400b001a2a904c42emr6232907ple.24.1680449701326; Sun, 02 Apr 2023 08:35:01 -0700 (PDT) Received: from localhost (157-131-78-143.fiber.dynamic.sonic.net. [157.131.78.143]) by smtp.gmail.com with ESMTPSA id h4-20020a170902704400b0019a593e45f1sm4893511plt.261.2023.04.02.08.34.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Apr 2023 08:35:00 -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: <87h6tymzzc.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> <87h6tzjejv.fsf@gmail.com> <87h6tymzzc.fsf@localhost> Date: Sun, 02 Apr 2023 08:34:59 -0700 Message-ID: <87edp2jo0s.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=jackkamm@gmail.com; helo=mail-pj1-x102c.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=1680449737; a=rsa-sha256; cv=none; b=lr6TEEk1+V3IDhGFYANoqgNDhO7mrWof3fNlBGS+/PCjPQi50hqrfBt2PI6ocf5bkd/6Ti +hBjytKk/pUDvWuP8zXtblVsdZFAXVCxaKkEiV3lVj4GP0PxKF6nEVg6DtNytb60wP5HHY VqkOTmuT21/To6xVtoda+GqpnSWiEn2/hSVAt5JHlmDJfax8RttoZ26End9ENuVdv4+3Vl ypGMAo8m4+IuMoFOlayNQ/XIsOvHA6QTJHpwOUXHGP78YzZVa+Th0OW/gPaJ6jm1DsmqUQ qKZ/ZHKigBYhb9hVs2m2/S5JcHJODgqiKDhNnESsETu/5Di823cPOnWv8HYNuQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20210112 header.b="GAplw/Jz"; 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=1680449737; 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=71dRxwaXdLQcWBBhG4gZiAW7HhkbTNadNzYTyCFEblk=; b=A1nnqOEaULb5/+feCcGmOAb9lWb900QxRG5F5W0wCQPPWd6a//RTK+AXwfvRnDZNOg1ctz hF7hvzxRM5UvP2pHUMw61zYTIDx8SPZZTuxletY0ihSoAlSXr+qJE7ZdVWnemZ1+YpDuAT FIEiiZ5zJ3O1+tJFSwhkn1np9RJUPiB3njDFXpCiSJo/mUgsEfkbff+BSEkCmB2dnH+2WQ 0oxlwVZrKmEFe6/q5sOU+LmBn51djs/A/OUl411+5mojhWvdL+gdOqjR3x1bXACldzXVTG jaCK0N3Ag82Pn5Nzkki8PnXN0TSp9M3srIIlfNPdnHYV4dPYhAJQhPUUJhiFrA== Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20210112 header.b="GAplw/Jz"; 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.23 X-Spam-Score: -1.23 X-Migadu-Queue-Id: 1F183251F8 X-TUID: MDFpiIFkwaCr --=-=-= Content-Type: text/plain Ihor Radchenko writes: > Looks reasonable, but I have one comment on the code. > We should not use user-defined hooks for things that must be executed. > Instead, we should better explicitly call the necessary functions. Thanks, I updated the patch to explicitly call the function. Also, I tweaked the coding-system-for-write to be a bit safer, in case of edge cases where utf-8 doesn't work -- I think RFC 5545 just says it's the default charset. Attached is the (I think) final version of the patch. I'll install it soon, unless I hear otherwise. PS I haven't forgotten your feedback on the original VTODO-related patches (thanks for that review). I'll work on that next, but it might take me a bit longer. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-ox-icalendar-Use-consistent-CRLF-line-endings.patch >From aa59625cd08dcee767f42ad8d45d8902aa8d38bd 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--post-process-file'. (org-icalendar--post-process-file): New function to handle exported file post-processing. Converts EOL to CRLF, and then runs `org-icalendar-after-save-hook'. (org-icalendar-export-to-ics, org-icalendar-export-current-agenda, org-icalendar--combine-files): Call `org-icalendar--post-process-file' instead of running `org-icalendar-after-save-hook' directly. * 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 | 27 ++++++++++++------- testing/lisp/test-ox-icalendar.el | 44 +++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 9 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..ccc237721 100644 --- a/lisp/ox-icalendar.el +++ b/lisp/ox-icalendar.el @@ -540,12 +540,23 @@ (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--post-process-file (file) + "Post-process the exported iCalendar FILE. +Converts line endings to dos-style CRLF as per RFC 5545, then +runs `org-icalendar-after-save-hook'." + (with-temp-buffer + (insert-file-contents file) + (let ((coding-system-for-write (coding-system-change-eol-conversion + last-coding-system-used 'dos))) + (write-region nil nil file))) + (run-hook-with-args 'org-icalendar-after-save-hook file) + nil) ;;; Filters @@ -932,8 +943,7 @@ (defun org-icalendar-export-to-ics (org-export-to-file 'icalendar outfile async subtreep visible-only body-only '(:ascii-charset utf-8 :ascii-links-to-notes nil) - '(lambda (file) - (run-hook-with-args 'org-icalendar-after-save-hook file) nil)))) + #'org-icalendar--post-process-file))) ;;;###autoload (defun org-icalendar-export-agenda-files (&optional async) @@ -1019,7 +1029,7 @@ (defun org-icalendar-export-current-agenda (file) (or (org-string-nw-p org-icalendar-timezone) (format-time-string "%Z")) org-icalendar-combined-description contents))) - (run-hook-with-args 'org-icalendar-after-save-hook file))) + (org-icalendar--post-process-file file))) (defun org-icalendar--combine-files (&rest files) "Combine entries from multiple files into an iCalendar file. @@ -1061,8 +1071,7 @@ (defun org-icalendar--combine-files (&rest files) (when (and org-icalendar-include-bbdb-anniversaries (require 'ol-bbdb nil t)) (with-output-to-string (org-bbdb-anniv-export-ical))))))) - (run-hook-with-args 'org-icalendar-after-save-hook - org-icalendar-combined-agenda-file)) + (org-icalendar--post-process-file org-icalendar-combined-agenda-file)) (org-release-buffers org-agenda-new-buffers)))) 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 --=-=-=--