From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: hokomo Newsgroups: gmane.emacs.bugs Subject: bug#56241: [PATCH] icalendar doesn't correctly process arbitrary diary sexp entries Date: Sun, 26 Jun 2022 20:36:46 +0200 Message-ID: <21bff87f-b8dc-c7bc-41ab-97c7077a0535@airmail.cc> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------JvJd182OBMvd6wzHkoaldjOz" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4693"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 To: 56241@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jun 26 23:15:35 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o5ZbT-0000vx-Gl for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 26 Jun 2022 23:15:35 +0200 Original-Received: from localhost ([::1]:41862 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o5ZbR-0005p6-UU for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 26 Jun 2022 17:15:33 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47604) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o5Zaw-0005nw-AN for bug-gnu-emacs@gnu.org; Sun, 26 Jun 2022 17:15:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:55340) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o5Zaw-0005a8-1r for bug-gnu-emacs@gnu.org; Sun, 26 Jun 2022 17:15:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1o5Zav-0003zp-Tb for bug-gnu-emacs@gnu.org; Sun, 26 Jun 2022 17:15:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: hokomo Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 26 Jun 2022 21:15:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 56241 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.165627807415298 (code B ref -1); Sun, 26 Jun 2022 21:15:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 26 Jun 2022 21:14:34 +0000 Original-Received: from localhost ([127.0.0.1]:49235 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o5ZaQ-0003ya-3T for submit@debbugs.gnu.org; Sun, 26 Jun 2022 17:14:34 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:39418) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o5X7y-00045L-25 for submit@debbugs.gnu.org; Sun, 26 Jun 2022 14:37:01 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47614) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o5X7x-0001Ua-KZ for bug-gnu-emacs@gnu.org; Sun, 26 Jun 2022 14:36:57 -0400 Original-Received: from [37.120.193.124] (port=50080 helo=mail.cock.li) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o5X7t-00046l-Iu for bug-gnu-emacs@gnu.org; Sun, 26 Jun 2022 14:36:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=airmail.cc; s=mail; t=1656268607; bh=UPYD2zmxkZp0r+lPf/zboLkrFUZPiCUkaZgdqxhlAFM=; h=Date:To:From:Subject:From; b=OAY48TtqDqRCtcIAcjdIe/OUGTeY+oZ9xAPdZTug8DwCYl4ant+kRkv/Ea/xSdU2m 75a6IK1BkNnJgLujLkpDfcHdN6yCYfIjk4dxrpYkcFbQWYuXE8BYV61JlWZwGmebac 0J4KidDvljb4/zo/dmEFfAGh74hjxXZp2o6R/U4TTJwTG+K+QinWtO2iO8PHXOiMWO 5yqXPicMEHqOWwlBYqtmUwj1m3WJ802ftzskPQVdswDmdqzZ4vTFyXNzDrC8ITRCct 6zrCQYDeczsO1nhNPP/q4HdjwHZvbriCbXWLG6UmEZP7so3HXbPay05Gzt8dgXmSgB h3Bj9ygEvgfKA== Content-Language: en-US X-Host-Lookup-Failed: Reverse DNS lookup failed for 37.120.193.124 (failed) Received-SPF: pass client-ip=37.120.193.124; envelope-from=hokomo@airmail.cc; helo=mail.cock.li X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sun, 26 Jun 2022 17:14:28 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:235403 Archived-At: This is a multi-part message in MIME format. --------------JvJd182OBMvd6wzHkoaldjOz Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit icalendar is capable of exporting arbitrary diary sexp entries, but it looks like there's a bug in the code. Each conversion function `icalendar--convert-*-to-ical' can return either a dotted pair or a list of such pairs, but the code fails to differentiate the two cases properly. To reproduce: (require 'icalendar) (defun test-diary-sexp (sexp) (message "Testing %S\n" sexp) (let ((file (make-temp-file "export.ics"))) (with-temp-buffer (insert sexp) (icalendar-export-region (point-min) (point-max) file)) (with-current-buffer (get-buffer "*icalendar-errors*") (message "export: %S\n" (with-temp-buffer (insert-file-contents file) (buffer-string))) (message "errors: %S" (buffer-string)))) (terpri)) (defun my-float (&rest args) (apply #'diary-float args)) (let ((icalendar-export-sexp-enumeration-days 366)) (test-diary-sexp "%%(diary-float 7 0 1) First Sunday in July 1") (test-diary-sexp "%%(my-float 7 0 1) First Sunday in July 2")) Exporting the my-float sexp will fail with: "Error in line 0 -- (wrong-type-argument listp First Sunday in July 2): ‘%%(my-float 7 0 1) First Sunday in July 2" because the returned list is confused for a dotted pair. `icalendar-export-sexp-enumeration-days' is set to 366 to guarantee that the sexp event occurs at least once. It looks like there's a different bug (?) where, even if an entry is recognized as an arbitrary diary sexp, if it doesn't produce any events, the converter will go ahead with trying to interpret it in a different way and eventually fail. E.g., lowering the enumeration days to 0 gives: "Error in line 0 -- (error Could not parse date): ‘%%(my-float 7 0 1) First Sunday in July 2’" after exhausting all of the known entry types. Should I file this as a separate bug? Regards, hokomo --------------JvJd182OBMvd6wzHkoaldjOz Content-Type: text/x-patch; charset=UTF-8; name="0001-Fix-detecting-dotted-pairs.patch" Content-Disposition: attachment; filename="0001-Fix-detecting-dotted-pairs.patch" Content-Transfer-Encoding: base64 RnJvbSA2OTFmMzRhMzAxMzU5ODkzYmNmZmZmO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bmQgKGNvbnNw IGNucy1jb25zLW9yLWxpc3QpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChub3Qg KGxpc3RwIChjZHIgY25zLWNvbnMtb3ItbGlzdCkpKSkKICAgICAgICAgICAgICAgICAgICAg ICAgIChsaXN0IGNucy1jb25zLW9yLWxpc3QpCiAgICAgICAgICAgICAgICAgICAgICAgY25z LWNvbnMtb3ItbGlzdCkpKQogICAgICAgICAgIDs7IGhhbmRsZSBlcnJvcnMKLS0gCjIuMzUu MwoK --------------JvJd182OBMvd6wzHkoaldjOz--