[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 8b15ce8 1/3: Make gnus-icalendar-event-from-ical more robust
From: |
Lars Ingebrigtsen |
Subject: |
master 8b15ce8 1/3: Make gnus-icalendar-event-from-ical more robust |
Date: |
Wed, 11 Aug 2021 08:58:31 -0400 (EDT) |
branch: master
commit 8b15ce8daa1c8ad4fa948b7b58057441819e58c1
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
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.
---
lisp/gnus/gnus-icalendar.el | 46 ++++++++++++++++++++++++++-------------------
1 file changed, 27 insertions(+), 19 deletions(-)
diff --git a/lisp/gnus/gnus-icalendar.el b/lisp/gnus/gnus-icalendar.el
index 56f4fdf..5294b83 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.