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

Previous Next

Package: emacs;

Reported by: hokomo <hokomo <at> airmail.cc>

Date: Sun, 26 Jun 2022 21:15:01 UTC

Severity: normal

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: hokomo <hokomo <at> airmail.cc>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] icalendar doesn't correctly process arbitrary diary sexp
 entries
Date: Sun, 26 Jun 2022 20:36:46 +0200
[Message part 1 (text/plain, inline)]
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 (text/x-patch, attachment)]

This bug report was last modified 1 year and 141 days ago.

Previous Next


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