summaryrefslogtreecommitdiff
path: root/lisp/gnus/gnus-icalendar.el
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2021-08-11 14:52:32 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2021-08-11 14:52:32 +0200
commit8b15ce8daa1c8ad4fa948b7b58057441819e58c1 (patch)
tree5014221b1327e9968299fb7be6b2790e4955929d /lisp/gnus/gnus-icalendar.el
parent024e6d213cfd6a0f273d485003e1c37e061ef227 (diff)
downloademacs-8b15ce8daa1c8ad4fa948b7b58057441819e58c1.tar.gz
emacs-8b15ce8daa1c8ad4fa948b7b58057441819e58c1.tar.bz2
emacs-8b15ce8daa1c8ad4fa948b7b58057441819e58c1.zip
Make gnus-icalendar-event-from-ical more robust
* lisp/gnus/gnus-icalendar.el (gnus-icalendar-event-from-ical): Don't bug out on nil UIDs.
Diffstat (limited to 'lisp/gnus/gnus-icalendar.el')
-rw-r--r--lisp/gnus/gnus-icalendar.el46
1 files changed, 27 insertions, 19 deletions
diff --git a/lisp/gnus/gnus-icalendar.el b/lisp/gnus/gnus-icalendar.el
index 56f4fdf6d33..5294b83d9e9 100644
--- a/lisp/gnus/gnus-icalendar.el
+++ b/lisp/gnus/gnus-icalendar.el
@@ -222,28 +222,32 @@
(uid . UID)))
(method (caddr (assoc 'METHOD (caddr (car (nreverse ical))))))
(attendee (when attendee-name-or-email
- (gnus-icalendar-event--find-attendee ical attendee-name-or-email)))
+ (gnus-icalendar-event--find-attendee
+ ical attendee-name-or-email)))
(attendee-names (gnus-icalendar-event--get-attendee-names ical))
(role (plist-get (cadr attendee) 'ROLE))
(participation-type (pcase role
- ("REQ-PARTICIPANT" 'required)
- ("OPT-PARTICIPANT" 'optional)
- (_ 'non-participant)))
+ ("REQ-PARTICIPANT" 'required)
+ ("OPT-PARTICIPANT" 'optional)
+ (_ 'non-participant)))
(zone-map (icalendar--convert-all-timezones ical))
- (args (list :method method
- :organizer organizer
- :start-time (gnus-icalendar-event--decode-datefield event 'DTSTART zone-map)
- :end-time (gnus-icalendar-event--decode-datefield event 'DTEND zone-map)
- :rsvp (string= (plist-get (cadr attendee) 'RSVP) "TRUE")
- :participation-type participation-type
- :req-participants (car attendee-names)
- :opt-participants (cadr attendee-names)))
- (event-class (cond
- ((string= method "REQUEST") 'gnus-icalendar-event-request)
- ((string= method "CANCEL") 'gnus-icalendar-event-cancel)
- ((string= method "REPLY") 'gnus-icalendar-event-reply)
- (t 'gnus-icalendar-event))))
-
+ (args
+ (list :method method
+ :organizer organizer
+ :start-time (gnus-icalendar-event--decode-datefield
+ event 'DTSTART zone-map)
+ :end-time (gnus-icalendar-event--decode-datefield
+ event 'DTEND zone-map)
+ :rsvp (string= (plist-get (cadr attendee) 'RSVP) "TRUE")
+ :participation-type participation-type
+ :req-participants (car attendee-names)
+ :opt-participants (cadr attendee-names)))
+ (event-class
+ (cond
+ ((string= method "REQUEST") 'gnus-icalendar-event-request)
+ ((string= method "CANCEL") 'gnus-icalendar-event-cancel)
+ ((string= method "REPLY") 'gnus-icalendar-event-reply)
+ (t 'gnus-icalendar-event))))
(cl-labels
((map-property
(prop)
@@ -271,7 +275,11 @@
for keyword = (intern
(format ":%s" (eieio-slot-descriptor-name slot)))
when (plist-member args keyword)
- append (list keyword (plist-get args keyword)))))))
+ append (list keyword
+ (if (eq keyword :uid)
+ ;; The UID has to be a string.
+ (or (plist-get args keyword) "")
+ (plist-get args keyword))))))))
(defun gnus-icalendar-event-from-buffer (buf &optional attendee-name-or-email)
"Parse RFC5545 iCalendar in buffer BUF and return an event object.