GNU bug report logs - #56241
[PATCH] icalendar doesn't correctly process arbitrary diary sexp entries

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: hokomo <hokomo@HIDDEN>; Keywords: patch; dated Sun, 26 Jun 2022 21:15:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 56241 <at> debbugs.gnu.org:


Received: (at 56241) by debbugs.gnu.org; 28 Jun 2022 11:22:20 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jun 28 07:22:19 2022
Received: from localhost ([127.0.0.1]:54073 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1o69IR-0000Zz-OK
	for submit <at> debbugs.gnu.org; Tue, 28 Jun 2022 07:22:19 -0400
Received: from quimby.gnus.org ([95.216.78.240]:47426)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1o69IP-0000ZZ-Ri
 for 56241 <at> debbugs.gnu.org; Tue, 28 Jun 2022 07:22:18 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org;
 s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:
 References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:
 Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
 Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=4yrrm+SuWzHKEZT/GcHLMO2f5GrpUp2JQ8yXJ8F2+/M=; b=OsyaX/FIHvOKeu74KB/IS6aDWI
 YmgyY9mGnSdDiazBM0nrV4M5z7LHkW8XAJ2Vwy1rSbz++1uR3govzufrAHO+ELuhQX0z/U0aWnqfr
 8H3+2/FfN6PMrJ6RvPU961kkfYUYpRyOYmpzlFGWJL2QQuIJLmuCumM+U6iuuvIkGq7w=;
Received: from [84.212.220.105] (helo=xo)
 by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.92) (envelope-from <larsi@HIDDEN>)
 id 1o69Hx-0001TS-Mv; Tue, 28 Jun 2022 13:22:00 +0200
From: Lars Ingebrigtsen <larsi@HIDDEN>
To: hokomo <hokomo@HIDDEN>
Subject: Re: bug#56241: [PATCH] icalendar doesn't correctly process
 arbitrary diary sexp entries
References: <21bff87f-b8dc-c7bc-41ab-97c7077a0535@HIDDEN>
 <87edza8rbu.fsf@HIDDEN>
 <a9a422de-ac0e-364e-b7af-c1acb02cd7cd@HIDDEN>
X-Now-Playing: Rev. J. M. Gates's _Anthology of American Folk Music: Social
 Music (2)_: "You Must Be Born Again"
Date: Tue, 28 Jun 2022 13:21:48 +0200
In-Reply-To: <a9a422de-ac0e-364e-b7af-c1acb02cd7cd@HIDDEN>
 (hokomo@HIDDEN's message of "Mon, 27 Jun 2022 11:42:34 +0200")
Message-ID: <87mtdxt4mr.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 Content preview:  hokomo <hokomo@HIDDEN> writes: > Yep, you can use the
 same testing script and just replace the last > expression with: > > (let
 ((icalendar-export-sexp-enumeration-days 0)) > (test-diary-sexp
 "%%(diary-float 7 0 1) First Sunday in [...] 
 Content analysis details:   (-2.9 points, 5.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
 [score: 0.0000]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 56241
Cc: Ulf Jasper <ulf.jasper@HIDDEN>, 56241 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

hokomo <hokomo@HIDDEN> writes:

> Yep, you can use the same testing script and just replace the last
> expression with:
>
> (let ((icalendar-export-sexp-enumeration-days 0))
>   (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"))
>
> which should give you the error I mentioned.

Right; I can reproduce that problem.  I've added Ulf to the CCs; perhaps
he has some comments.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#56241; Package emacs. Full text available.

Message received at 56241 <at> debbugs.gnu.org:


Received: (at 56241) by debbugs.gnu.org; 27 Jun 2022 12:31:32 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jun 27 08:31:31 2022
Received: from localhost ([127.0.0.1]:50223 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1o5ntn-0006zN-Ox
	for submit <at> debbugs.gnu.org; Mon, 27 Jun 2022 08:31:31 -0400
Received: from [37.120.193.124] (port=34734 helo=mail.cock.li)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <hokomo@HIDDEN>) id 1o5lGU-00083E-Q3
 for 56241 <at> debbugs.gnu.org; Mon, 27 Jun 2022 05:42:47 -0400
Content-Type: multipart/mixed; boundary="------------x92lbi8WXdL97kq43XFKoufV"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=airmail.cc; s=mail;
 t=1656322955; bh=VStskTBxz/jmr8YJe6Jxh63ZUdgk4DqmVbDVgrRDyZU=;
 h=Date:Subject:To:Cc:References:From:In-Reply-To:From;
 b=Jjzcp5RQb+AMigMzRzzXGO0r8BM1fodFtsCAQZ9jTMeqOoKuRuJPbrsfZV8aJXfe5
 9I6uKwkEwvNMpeJio/Te1YhsVBfDabVLJGASoeZGQEwG5biiI8/4jAsbdnemdNiMcW
 qoIUQopuRpkO+8AqyOZ1MUA79A6JMQCpRwUai7b2QAiigXTnHAsVd0+kNLU6AY0Cex
 jCAzYD14VDF93Ls2+X2RglIAoYx9HsledGdtvt4tQEu5f6rMRhQCrkRSzhQMPD8EH8
 FvhWPk0Q49cgXL2itwD/NFZ/WQPC0P0pC2Voy+cMFVCNCQRo3YWLzayZ+JtwSnLJHx
 GslOaKm8lpaHg==
Message-ID: <a9a422de-ac0e-364e-b7af-c1acb02cd7cd@HIDDEN>
Date: Mon, 27 Jun 2022 11:42:34 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.10.0
Subject: Re: bug#56241: [PATCH] icalendar doesn't correctly process arbitrary
 diary sexp entries
Content-Language: en-US
To: Lars Ingebrigtsen <larsi@HIDDEN>
References: <21bff87f-b8dc-c7bc-41ab-97c7077a0535@HIDDEN>
 <87edza8rbu.fsf@HIDDEN>
From: hokomo <hokomo@HIDDEN>
In-Reply-To: <87edza8rbu.fsf@HIDDEN>
X-Spam-Score: 1.3 (+)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview:  >> `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 a [...] 
 Content analysis details:   (1.3 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 0.0 T_SPF_HELO_TEMPERROR   SPF: test of HELO record failed (temperror)
 -0.0 SPF_PASS               SPF: sender matches SPF record
 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS
 -0.0 T_SCC_BODY_TEXT_LINE   No description available.
 -0.0 NICE_REPLY_A           Looks like a legit reply (A)
X-Debbugs-Envelope-To: 56241
X-Mailman-Approved-At: Mon, 27 Jun 2022 08:31:26 -0400
Cc: 56241 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.3 (/)

This is a multi-part message in MIME format.
--------------x92lbi8WXdL97kq43XFKoufV
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

>> `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?
> 
> No, we can work on this problem here in this bug report.
> 
> Do you have a recipe to reproduce the problem, starting from "emacs -Q"?

Yep, you can use the same testing script and just replace the last 
expression with:

(let ((icalendar-export-sexp-enumeration-days 0))
   (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"))

which should give you the error I mentioned. I don't have a patch for 
this on hand but it would probably require restructuring the surrounding 
code a little bit.

There's another bug that concerns sexps that contain more than a single 
closing parenthesis. Seems like the icalendar code uses a bunch of 
regexes to parse the sexp (see `icalendar--convert-sexp-to-ical'), 
rather than something like `read' or `read-from-string' (which is what 
diary does, as well as org-agenda). To reproduce (with the same testing 
code as before):

(let ((icalendar-export-sexp-enumeration-days 366))
   (test-diary-sexp "%%(= (calendar-day-of-week date) 0) Sunday 1")
   (test-diary-sexp "%%(= 0 (calendar-day-of-week date)) Sunday 2"))

No matter whether the closing parentheses are bunched together or 
separated, parsing fails either way. I've attached a draft of a patch 
that modifies as little as possible and makes the above two cases work, 
but that's not enough as there's special handling of `and' forms. 
Furthermore, sexps that span multiple lines fail for the same reason, 
even though diary handles them just fine of course. Ideally the whole 
function should be rewritten to just use `read-from-string'. I don't 
understand why `and' forms are handled specially though, so I'm not sure 
how to proceed here.

A last thing to note -- even though org-agenda properly handles 
multiline sexps and sexps with an arbitrary number of closing 
parentheses (because it does the parsing manually and uses 
`forward-sexp'), Org's parser itself does not properly handle multiline 
sexps (but does handle multiple closing parentheses). To confirm, use 
`org-element-at-point' at the beginning of these two diary sexps in an 
org-mode buffer:

%%(let ((a 123) (b 456)) (+ a b))

%%(let ((a 123)
         (b 456))
    (+ a b))

All of these bugs also propagate to ox-icalendar (which is how I got 
into exploring this whole thing) since it relies on the Org parse tree 
to pull out 'diary-sexp elements and on icalendar to export them into 
iCalendar format.

Let me know if you want me to report any of these as separate bugs and 
what would be the best thing to do here.

Regards,
hokomo
--------------x92lbi8WXdL97kq43XFKoufV
Content-Type: text/x-patch; charset=UTF-8;
 name="0002-Draft-fix-nested-diary-sexps.patch"
Content-Disposition: attachment;
 filename="0002-Draft-fix-nested-diary-sexps.patch"
Content-Transfer-Encoding: base64

RnJvbSBlMzVlYTFmM2E5YzYyZDljMDdkMTBkOWVjODliZjg3OTA1ODc3NWMyIE1vbiBTZXAg
MTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBob2tvbW8gPGhva29tb0BhaXJtYWlsLmNjPgpEYXRl
OiBTYXQsIDI1IEp1biAyMDIyIDEzOjQzOjI4ICswMjAwClN1YmplY3Q6IFtQQVRDSF0gRml4
IG5lc3RlZCBkaWFyeSBzZXhwcwoKLS0tCiBsaXNwL2NhbGVuZGFyL2ljYWxlbmRhci5lbCB8
IDggKysrKystLS0KIDEgZmlsZSBjaGFuZ2VkLCA1IGluc2VydGlvbnMoKyksIDMgZGVsZXRp
b25zKC0pCgpkaWZmIC0tZ2l0IGEvbGlzcC9jYWxlbmRhci9pY2FsZW5kYXIuZWwgYi9saXNw
L2NhbGVuZGFyL2ljYWxlbmRhci5lbAppbmRleCA0NmJjZjQ1NjZmLi4yYjZhZjc5ODEyIDEw
MDY0NAotLS0gYS9saXNwL2NhbGVuZGFyL2ljYWxlbmRhci5lbAorKysgYi9saXNwL2NhbGVu
ZGFyL2ljYWxlbmRhci5lbApAQCAtMTY0MSw5ICsxNjQxLDExIEBAIGljYWxlbmRhci0tY29u
dmVydC1zZXhwLXRvLWljYWwKICAgICAgICAgICAgICAgICAgICAgICAgZW50cnktbWFpbikK
ICAgICAgICAgIDs7IHJlZ3VsYXIgc2V4cCBlbnRyeQogICAgICAgICAgKGljYWxlbmRhci0t
ZG1zZyAiZGlhcnktc2V4cCAlcyIgZW50cnktbWFpbikKLSAgICAgICAgIChsZXQgKChwMSAo
c3Vic3RyaW5nIGVudHJ5LW1haW4gKG1hdGNoLWJlZ2lubmluZyAxKSAobWF0Y2gtZW5kIDEp
KSkKLSAgICAgICAgICAgICAgIChwMiAoc3Vic3RyaW5nIGVudHJ5LW1haW4gKG1hdGNoLWJl
Z2lubmluZyAyKSAobWF0Y2gtZW5kIDIpKSkKLSAgICAgICAgICAgICAgIChub3cgKG9yIHN0
YXJ0IChjdXJyZW50LXRpbWUpKSkpCisgICAgICAgICAobGV0KiAoKGVudHJ5LW1haW4gKHN1
YnN0cmluZyBlbnRyeS1tYWluIDIpKQorICAgICAgICAgICAgICAgIChyZXMgKHJlYWQtZnJv
bS1zdHJpbmcgZW50cnktbWFpbikpCisgICAgICAgICAgICAgICAgKHAxIChwcmluMS10by1z
dHJpbmcgKGNhciByZXMpKSkKKyAgICAgICAgICAgICAgICAocDIgKHN1YnN0cmluZyBlbnRy
eS1tYWluIChjZHIgcmVzKSkpCisgICAgICAgICAgICAgICAgKG5vdyAob3Igc3RhcnQgKGN1
cnJlbnQtdGltZSkpKSkKICAgICAgICAgICAgKGRlbGV0ZSBuaWwKICAgICAgICAgICAgICAg
ICAgICAobWFwY2FyCiAgICAgICAgICAgICAgICAgICAgIChsYW1iZGEgKG9mZnNldCkKLS0g
CjIuMzUuMwoK

--------------x92lbi8WXdL97kq43XFKoufV--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#56241; Package emacs. Full text available.

Message received at 56241 <at> debbugs.gnu.org:


Received: (at 56241) by debbugs.gnu.org; 27 Jun 2022 08:05:07 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jun 27 04:05:07 2022
Received: from localhost ([127.0.0.1]:49736 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1o5jk3-0007aa-CZ
	for submit <at> debbugs.gnu.org; Mon, 27 Jun 2022 04:05:07 -0400
Received: from quimby.gnus.org ([95.216.78.240]:34442)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1o5jk0-0007ZS-QV
 for 56241 <at> debbugs.gnu.org; Mon, 27 Jun 2022 04:05:06 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org;
 s=20200322; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID
 :In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID:
 Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc
 :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe:
 List-Post:List-Owner:List-Archive;
 bh=ZnarujxQk3TU5g9Qaxl0MOWVFm6x94ex6eytLt6QC3o=; b=lFKCYlEyuqLDzRtfm9wm5+zbZg
 KZDxvkagbHBN8NhDRXhbOT6rxigwLEB9Rd5bry7e1ixYfbI8n/Ghs2KU+qUbzfGwVC6ZnYprUsgB0
 6exuO77gEoU7FIDlcVN0kZpc849pFTgYa2xXugGBPZ/7Ej0iGIds73pwSecjvxhpO9ek=;
Received: from [84.212.220.105] (helo=xo)
 by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.92) (envelope-from <larsi@HIDDEN>)
 id 1o5jjq-0003Ny-0g; Mon, 27 Jun 2022 10:04:56 +0200
From: Lars Ingebrigtsen <larsi@HIDDEN>
To: hokomo <hokomo@HIDDEN>
Subject: Re: bug#56241: [PATCH] icalendar doesn't correctly process
 arbitrary diary sexp entries
References: <21bff87f-b8dc-c7bc-41ab-97c7077a0535@HIDDEN>
Date: Mon, 27 Jun 2022 10:04:53 +0200
In-Reply-To: <21bff87f-b8dc-c7bc-41ab-97c7077a0535@HIDDEN>
 (hokomo@HIDDEN's message of "Sun, 26 Jun 2022 20:36:46 +0200")
Message-ID: <87edza8rbu.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 
 Content preview:  hokomo <hokomo@HIDDEN> writes: > 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 [...] 
 
 Content analysis details:   (-2.9 points, 5.0 required)
 
  pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
                             [score: 0.0000]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 56241
Cc: 56241 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

hokomo <hokomo@HIDDEN> writes:

> Exporting the my-float sexp will fail with:
>
> "Error in line 0 -- (wrong-type-argument listp First Sunday in July
> 2): =E2=80=98%%(my-float 7 0 1) First Sunday in July 2"
>
> because the returned list is confused for a dotted pair.

Thanks; patch pushed to Emacs 29.

> `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): =E2=80=98%%(my-float 7 =
0 1)
> First Sunday in July 2=E2=80=99"
>
> after exhausting all of the known entry types. Should I file this as a
> separate bug?

No, we can work on this problem here in this bug report.

Do you have a recipe to reproduce the problem, starting from "emacs -Q"?

--=20
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#56241; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 26 Jun 2022 21:14:34 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jun 26 17:14:34 2022
Received: from localhost ([127.0.0.1]:49235 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1o5ZaQ-0003ya-3T
	for submit <at> debbugs.gnu.org; Sun, 26 Jun 2022 17:14:34 -0400
Received: from lists.gnu.org ([209.51.188.17]:39418)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <hokomo@HIDDEN>) id 1o5X7y-00045L-25
 for submit <at> debbugs.gnu.org; Sun, 26 Jun 2022 14:37:01 -0400
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 <hokomo@HIDDEN>) id 1o5X7x-0001Ua-KZ
 for bug-gnu-emacs@HIDDEN; Sun, 26 Jun 2022 14:36:57 -0400
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 <hokomo@HIDDEN>) id 1o5X7t-00046l-Iu
 for bug-gnu-emacs@HIDDEN; Sun, 26 Jun 2022 14:36:56 -0400
Content-Type: multipart/mixed; boundary="------------JvJd182OBMvd6wzHkoaldjOz"
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==
Message-ID: <21bff87f-b8dc-c7bc-41ab-97c7077a0535@HIDDEN>
Date: Sun, 26 Jun 2022 20:36:46 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.10.0
Content-Language: en-US
To: bug-gnu-emacs@HIDDEN
From: hokomo <hokomo@HIDDEN>
Subject: [PATCH] icalendar doesn't correctly process arbitrary diary sexp
 entries
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@HIDDEN;
 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-Spam-Score: -1.4 (-)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Sun, 26 Jun 2022 17:14:28 -0400
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.4 (--)

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

RnJvbSA2OTFmMzRhMzAxMzU5ODkzYmNmZmZmOGU0ZTBjODc5NGExZmQ1ZTY4IE1vbiBTZXAg
MTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBob2tvbW8gPGhva29tb0BhaXJtYWlsLmNjPgpEYXRl
OiBTYXQsIDI1IEp1biAyMDIyIDA5OjQ0OjU0ICswMjAwClN1YmplY3Q6IFtQQVRDSF0gRml4
IGRldGVjdGluZyBkb3R0ZWQgcGFpcnMKCiogbGlzcC9jYWxlbmRhci9pY2FsZW5kYXIuZWwg
KGljYWxlbmRhci1leHBvcnQtcmVnaW9uKTogRml4IGRldGVjdGluZwpkb3R0ZWQgcGFpcnMu
Ci0tLQogbGlzcC9jYWxlbmRhci9pY2FsZW5kYXIuZWwgfCAzICsrLQogMSBmaWxlIGNoYW5n
ZWQsIDIgaW5zZXJ0aW9ucygrKSwgMSBkZWxldGlvbigtKQoKZGlmZiAtLWdpdCBhL2xpc3Av
Y2FsZW5kYXIvaWNhbGVuZGFyLmVsIGIvbGlzcC9jYWxlbmRhci9pY2FsZW5kYXIuZWwKaW5k
ZXggMWE1YTA3MWUyMC4uY2Y1NDI5Mzk4OSAxMDA2NDQKLS0tIGEvbGlzcC9jYWxlbmRhci9p
Y2FsZW5kYXIuZWwKKysrIGIvbGlzcC9jYWxlbmRhci9pY2FsZW5kYXIuZWwKQEAgLTExNDQs
NyArMTE0NCw4IEBAIGljYWxlbmRhci1leHBvcnQtcmVnaW9uCiAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgKGNkciBjb250ZW50cy1uLXN1bW1hcnkpKSkpCiAgICAg
ICAgICAgICAgICAgICAgICAgKHNldHEgcmVzdWx0IChjb25jYXQgcmVzdWx0IGhlYWRlciBj
b250ZW50cyBhbGFybQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICJcbkVORDpWRVZFTlQiKSkpCi0gICAgICAgICAgICAgICAgICAgIChpZiAoY29uc3Ag
Y25zLWNvbnMtb3ItbGlzdCkKKyAgICAgICAgICAgICAgICAgICAgKGlmIChhbmQgKGNvbnNw
IGNucy1jb25zLW9yLWxpc3QpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChub3Qg
KGxpc3RwIChjZHIgY25zLWNvbnMtb3ItbGlzdCkpKSkKICAgICAgICAgICAgICAgICAgICAg
ICAgIChsaXN0IGNucy1jb25zLW9yLWxpc3QpCiAgICAgICAgICAgICAgICAgICAgICAgY25z
LWNvbnMtb3ItbGlzdCkpKQogICAgICAgICAgIDs7IGhhbmRsZSBlcnJvcnMKLS0gCjIuMzUu
MwoK

--------------JvJd182OBMvd6wzHkoaldjOz--




Acknowledgement sent to hokomo <hokomo@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#56241; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Tue, 28 Jun 2022 11:30:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.