lpil / icalendar

🗓️ A small library for reading and writing ICalendar files.
MIT License
103 stars 56 forks source link

Wrapped ICal causes missed event lines #53

Closed sb8244 closed 2 years ago

sb8244 commented 3 years ago

I ran into an issue with Google calendar link where it would only bring in the first line of the description (or other long lines). This has to do with how Google wraps the API to a max column width.

My solution was to adapt the Ruby code to clean up the body before parsing it with ICal. For my link, it works as expected.

String.replace(body, ~r/\r?\n[ \t]/, "")

Is this something you'd want PR'd into this library? It seems like an important part of deserialization, and I'm positive there are other edge cases I'm missing now.

ICal Feed

BEGIN:VCALENDAR
PRODID:-//Google Inc//Google Calendar 70.9054//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:PUBLISH
X-WR-CALNAME:Clove Demo Events
X-WR-TIMEZONE:America/New_York
BEGIN:VTIMEZONE
TZID:America/New_York
X-LIC-LOCATION:America/New_York
BEGIN:DAYLIGHT
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
TZNAME:EDT
DTSTART:19700308T020000
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
TZNAME:EST
DTSTART:19701101T020000
RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
DTSTART;TZID=America/New_York:20210503T113000
DTEND;TZID=America/New_York:20210503T120000
DTSTAMP:20210505T171158Z
UID:6ou48vuri428dthd98kouog5m1@google.com
RECURRENCE-ID;TZID=America/New_York:20210503T113000
CREATED:20210505T163610Z
DESCRIPTION:We are here to bring you the top tips\, in a lightning format!
 We'll go over one or two of our most common features\, how to use it more e
 ffectively\, and answer any questions you have.<br><br>This training happen
 s twice a week\, so pick the time that's most convenient for you. There is
 naturally overlap between different trainings\, but we'll try to cover diff
 erent topics each time.<br><br>Join Zoom Meeting<br><a href="https://zoom.u
 s/j/97513611067?pwd=bkhzMkZQWjdrOUREMzNJSXNiOGxDQT09">https://zoom.us/j/975
 13611067?pwd=bkhzMkZQWjdrOUREMzNJSXNiOGxDQT09</a><br>Meeting ID: 975 1361 1
 067<br>Passcode: jdKY00Tzv1
LAST-MODIFIED:20210505T170420Z
LOCATION:Zoom
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:Product Tips Lightning Training Product Tips Lightning Training Pro
 duct Tips Lightning Training
TRANSP:OPAQUE
END:VEVENT
BEGIN:VEVENT
DTSTART;TZID=America/New_York:20210503T113000
DTEND;TZID=America/New_York:20210503T120000
RRULE:FREQ=WEEKLY;WKST=SU;BYDAY=FR,MO
EXDATE;TZID=America/New_York:20210507T113000
DTSTAMP:20210505T171158Z
UID:6ou48vuri428dthd98kouog5m1@google.com
CREATED:20210505T163610Z
DESCRIPTION:We are here to bring you the top tips\, in a lightning format!
 We'll go over one or two of our most common features\, how to use it more e
 ffectively\, and answer any questions you have.<br><br>This training happen
 s twice a week\, so pick the time that's most convenient for you. There is
 naturally overlap between different trainings\, but we'll try to cover diff
 erent topics each time.<br><br>Join Zoom Meeting<br><a href="https://zoom.u
 s/j/97513611067?pwd=bkhzMkZQWjdrOUREMzNJSXNiOGxDQT09">https://zoom.us/j/975
 13611067?pwd=bkhzMkZQWjdrOUREMzNJSXNiOGxDQT09</a><br>Meeting ID: 975 1361 1
 067<br>Passcode: jdKY00Tzv1
LAST-MODIFIED:20210505T163751Z
LOCATION:Zoom
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:Product Tips Lightning Training
TRANSP:OPAQUE
END:VEVENT
BEGIN:VEVENT
DTSTART;TZID=America/New_York:20210505T160000
DTEND;TZID=America/New_York:20210505T170000
RRULE:FREQ=WEEKLY;BYDAY=WE
DTSTAMP:20210505T171158Z
UID:53c032jfrpcg6ksrjfl4rei4qu@google.com
CREATED:20210505T160919Z
DESCRIPTION:Happy Wednesday! We hold a training every week in order to make
  sure you're set up for success.<br><br>Bring questions—the second half of
 the training will be led completely by what you want to know! The first hal
 f will follow based on our latest features and what we think you need to kn
 ow.<br><br>Join Zoom Meeting<br><a href="https://zoom.us/j/97513611067?pwd=
 bkhzMkZQWjdrOUREMzNJSXNiOGxDQT09">https://zoom.us/j/97513611067?pwd=bkhzMkZ
 QWjdrOUREMzNJSXNiOGxDQT09</a><br>Meeting ID: 975 1361 1067<br>Passcode: jdK
 Y00Tzv1
LAST-MODIFIED:20210505T161121Z
LOCATION:Zoom
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:Wednesday Training!
TRANSP:OPAQUE
END:VEVENT
END:VCALENDAR
lpil commented 3 years ago

Sounds like a good addition, let's add that with a link to this issue and the Ruby source for context.

Thank you for your patience waiting for me to reply to this issue.

axelson commented 2 years ago

I created a PR to fix this #61