sabre-io / vobject

:date: The VObject library for PHP allows you to easily parse and manipulate iCalendar and vCard objects
http://sabre.io/vobject/
BSD 3-Clause "New" or "Revised" License
569 stars 122 forks source link

Sabre Vobject can't parse ics generated by Deutsche Bahn #59

Closed georgehrke closed 10 years ago

georgehrke commented 10 years ago

Sabre vobject can't parse ics generated by Deutsche Bahn.

Error msg:

 22:59:08 MacBook-Air:~/Source Code/PHP > php demo.php
PHP Fatal error:  Uncaught exception 'Sabre\VObject\ParseException' with message 'Invalid Mimedir file. Line starting at 34 did not follow iCalendar/vCard conventions' in /Users/georgehrke/Source Code/PHP/sabre-vobject-master/lib/Sabre/VObject/Parser/MimeDir.php:356
Stack trace:
#0 /Users/georgehrke/Source Code/PHP/sabre-vobject-master/lib/Sabre/VObject/Parser/MimeDir.php(169): Sabre\VObject\Parser\MimeDir->readProperty('ab D??sseldorf-...')
#1 /Users/georgehrke/Source Code/PHP/sabre-vobject-master/lib/Sabre/VObject/Parser/MimeDir.php(152): Sabre\VObject\Parser\MimeDir->parseLine('ab D??sseldorf-...')
#2 /Users/georgehrke/Source Code/PHP/sabre-vobject-master/lib/Sabre/VObject/Parser/MimeDir.php(117): Sabre\VObject\Parser\MimeDir->parseLine('BEGIN:VEVENT')
#3 /Users/georgehrke/Source Code/PHP/sabre-vobject-master/lib/Sabre/VObject/Parser/MimeDir.php(61): Sabre\VObject\Parser\MimeDir->parseDocument()
#4 /Users/georgehrke/Source Code/PHP/sabre-vobject-master/lib/Sabre/VObject/Reader.php(44): Sabre\VObject\Parser\MimeDir->parse('B in /Users/georgehrke/Source Code/PHP/sabre-vobject-master/lib/Sabre/VObject/Parser/MimeDir.php on line 356

Example code:

<?php
require_once 'sabre-vobject-master/lib/Sabre/VObject/includes.php';

$ics = <<<EOF
BEGIN:VCALENDAR
X-LOTUS-CHARSET:ISO-8859-1
VERSION:2.0
PRODID:http://www.bahn.de
METHOD:PUBLISH
BEGIN:VTIMEZONE
TZID:Europe/Berlin
X-LIC-LOCATION:Europe/Berlin
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
TZNAME:CEST
DTSTART:19700329T020000
RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=3
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
TZNAME:CET
DTSTART:19701025T030000
RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=10
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
UID:bahn20130811071600
CLASS:PUBLIC
SUMMARY:Düsseldorf-Benrath -> Ilsenburg
DTSTART;TZID=Europe/Berlin:20130811T071600
DTEND;TZID=Europe/Berlin:20130811T123400
DTSTAMP:20130721T215400Z
DESCRIPTION:Reise: Düsseldorf-Benrath nach Ilsenburg\nDatum: 11.08.2013\n\nab Düsseldorf-Benrath 07:16\nan Ilsenburg 12:34\n\nAlle Angaben ohne Gewähr. Fahrplanänderungen vorbehalten. Bitte prüfen Sie kurz vor der Reise den aktuellen Fahrplan unter: www.bahn.de
END:VEVENT
END:VCALENDAR
EOF;

$vobject = Sabre\VObject\Reader::read($ics);
var_dump($vobject);
georgehrke commented 10 years ago

tested with latest master

evert commented 10 years ago

Thanks! That is very odd :S

evert commented 10 years ago

This error is actually expected in this case. Your sample code has literal newlines in them, instead of the expected literal \n.

If I replace the \n with \\n there is no error. Same on the 2.1 branch.

georgehrke commented 10 years ago

I'll close this for now and will try to find what causes https://github.com/owncloud/apps/issues/687 tomorrow.

georgehrke commented 10 years ago

thx for the help :)