Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parser crashes on invalid timezone #116

Closed
acmurmeltier69 opened this issue Mar 28, 2017 · 2 comments
Closed

Parser crashes on invalid timezone #116

acmurmeltier69 opened this issue Mar 28, 2017 · 2 comments

Comments

@acmurmeltier69
Copy link

acmurmeltier69 commented Mar 28, 2017

I have a calendar which uses timezone information with the TZID field

DTSTART;TZID=Germany/Berlin:20170303

and

DTSTART;TZID=Germany/Berlin;VALUE=DATE:20170413

this makes the parser crash

Fatal error: Uncaught exception 'Exception' with message 'DateTimeZone::__construct(): 
Unknown or bad timezone (Germany/Berlin)' in ICal\ICal.php:611
Stack trace: #0 ICal\ICal.php(611): DateTimeZone->__construct('Germany/Berlin') #1 ICal\ICal.php(1349): ICal\ICal->iCalDateWithTimeZone(Array, 'DTSTART', true) #2 ICal\ICal.php(318): ICal\ICal->processDateConversions() #3 ICal\ICal.php(180): ICal\ICal->initLines(Array) #4 index.php(8): ICal\ICal->__construct('abfuhrkalender_...') #5 {main} thrown in ICal\ICal.php on line 611

RFC5545 is unclear what terms for TZID need to be supported. It states

Note: This document does not define a naming convention for time zone identifiers. Implementers may want to use the naming conventions defined in existing time zone specifications such as the public-domain TZ database [TZDB]. The specification of globally unique time zone identifiers is not addressed by this document and is left for future study.

The ICAL validator https://icalendar.org/validator.html also returns

Invalid TZID value (Germany/Berlin) near line # 5
Reference: 3.2.19. Time Zone Identifier

As simple solution, I recommend to ignore the timezone information and issue a warning if the value for TZID cannot be parsed (i.e. put a try/except around the constructors for new \DateTimeZone($eventTimeZone); except when self::DEFAULT_TIMEZONE is used)

@u01jmg3 u01jmg3 self-assigned this Mar 28, 2017
@u01jmg3 u01jmg3 changed the title Parser crashes on invalid timzone tag Parser crashes on invalid timezone tag Mar 28, 2017
@u01jmg3
Copy link
Owner

u01jmg3 commented Mar 28, 2017

Got a fix coming

@u01jmg3 u01jmg3 modified the milestone: v2.x.x Mar 28, 2017
@u01jmg3 u01jmg3 changed the title Parser crashes on invalid timezone tag Parser crashes on invalid timezone Mar 28, 2017
@u01jmg3 u01jmg3 removed their assignment Mar 29, 2017
@acmurmeltier69
Copy link
Author

acmurmeltier69 commented Mar 29, 2017

Hi
No idea what happens precisely but the change introduced in 668ea04 suddenly causes an issue with a calendar entry that has no time zone info at all and worked before:

BEGIN:VCALENDAR
PRODID:-//sample MIMEDIR//EN
VERSION:2.0
METHOD:PUBLISH
BEGIN:VEVENT
DTSTART;VALUE=DATE:20170313
DTEND;VALUE=DATE:20170314
DESCRIPTION:Sample Event
LOCATION:Germany
RRULE:FREQ=WEEKLY;UNTIL=20171224T000000Z;INTERVAL=2;BYDAY=MO;WKST=SU
EXDATE;VALUE=DATE:20170410,20170605
TRANSP:TRANSPARENT
SEQUENCE:0
UID:14885238391@abc.de
DTSTAMP:20170303T065039Z
SUMMARY:Sample Event
CLASS:PUBLIC
CREATED:20170222T151357Z
LAST-MODIFIED:20170222T151357Z
END:VEVENT
END:VCALENDAR

The EXDATE is not applied correctly in the latest master.
If I bring back the } else if ($this->isValidTimeZoneId($eventTimeZone)) { in line 556 (was line 552 in 668ea04), the dates 20170410 and 20170605 are correctly excluded.

I flipped all changes individually. This seems to be the one causing the issue.
(Tested on my server in Germany)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants