[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#56241: [PATCH] icalendar doesn't correctly process arbitrary diary s
From: |
hokomo |
Subject: |
bug#56241: [PATCH] icalendar doesn't correctly process arbitrary diary sexp entries |
Date: |
Sun, 26 Jun 2022 20:36:46 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 |
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
0001-Fix-detecting-dotted-pairs.patch
Description: Text Data
- bug#56241: [PATCH] icalendar doesn't correctly process arbitrary diary sexp entries,
hokomo <=