Code Monkey home page Code Monkey logo

vobject's Introduction

sabre/vobject

The VObject library allows you to easily parse and manipulate iCalendar and vCard objects using PHP.

The goal of the VObject library is to create a very complete library, with an easy-to-use API.

Installation

Make sure you have Composer installed, and then run:

composer require sabre/vobject "^4.0"

This package requires PHP 5.5. If you need the PHP 5.3/5.4 version of this package instead, use:

composer require sabre/vobject "^3.4"

Usage

Build status

branch status
master Build Status
3.5 Build Status
3.4 Build Status
3.1 Build Status
2.1 Build Status
2.0 Build Status

Support

Head over to the SabreDAV mailing list for any questions.

Made at fruux

This library is being developed by fruux. Drop us a line for commercial services or enterprise support.

vobject's People

Contributors

ahackschmitz avatar come-nc avatar deepdiver1975 avatar dependabot[bot] avatar dominikto avatar evengard avatar evert avatar floerke avatar gharlan avatar grahamlinagora avatar heiglandreas avatar hollodk avatar hywan avatar icewind1991 avatar j03k64 avatar jaircuevajunior avatar jakobsack avatar jankantert avatar jeroenvanoort avatar johnrdorazio avatar kristofferfm avatar laoneo avatar mstilkerich avatar phil-davis avatar phpgangsta avatar pk1234 avatar remicollet avatar sash04ek avatar staabm avatar tanghus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vobject's Issues

Property parameter *value* with no name is interpreted as *name* with no value

The vCard 2.1 specification allows parameter values without a name. The parameter name is then determined from the unique parameter value.

The current parser and Parameter class incorrectly interpret it the other way around: a parameter name with no value.

vCard v2.1 specification:

The value string can be specified alone in those cases where the value is unambiguous. For example a complete property parameter specification might be:

NOTE;ENCODING=QUOTED-PRINTABLE:value skipped[...]

A valid short version of the same property parameter specification might be:

NOTE;QUOTED-PRINTABLE:value skipped[...]

Both vCard 3.0 and 4.0 specifications do not seem to allow this shortcut, at least I couldn't find anything related in the RFCs and their ABNFs explicitly require parameter names.

A list of default parameter names can probably be taken from vCard PHP (released under the BSD license):
https://github.com/barnabywalters/vcard/blob/master/barnabywalters/VCard/VCard.php#L205

Might be related to the new parser concept in ticket #31.

Adding more timezone guessing

Hi,

I don't know if it's worth adding ... I saw an additional list of timezones on the ZimbraServer for guessing timezones. I saw that it's included in another project, I want to switch from iCalcreator to VObjects agendav/agendav@cccaa68 but I just don't know if anyone uses those. The commit does not have any assumptions why this was added.

Here's an additional link to the ZimbraServer repository: http://zimbra.imladris.sk/download/src/HELIX-720.fbsd/ZimbraServer/conf/tz/
Here's the same list on the msdn portal: http://msdn.microsoft.com/en-us/library/ms912391%28v=winembedded.11%29.aspx

Bye
Simon

Create more specific exceptions

Currently LogicException and InvalidArgumentException is used liberally in the library.

These aren't very descriptive, and often even used inappropriately. We should improve this in a future release.

Enhancement: the case for Sabre\VObject\Property::select()

The VObject-3.0.0 API seems to be missing a Sabre\VObject\Property::select() property that works equivalently to Sabre\VObject\Component::select(), but for parameters. That would make the API more symmetrical and lead to less boilerplate code.

There is currently no API method for Sabre\VObject\Property for selecting a parameter by name, which returns an empty array when no matches are found. All the available parameter querying functions return either a nonempty array, or null. That makes those functions uniterable by foreach unless guarded by a clumsy null check. An example:

<?php

include('lib/SabreDAV/vendor/autoload.php');
use Sabre\VObject;

$card = new VObject\Component\VCard();
$elem = $card->add('TEL', '123');

// This works: select() returns an empty array, no harm no foul:
foreach ($card->select('NONEXIST') as $prop) {
    echo "not reached\n";
}

foreach ($card->select('TEL') as $prop)
{
        // ex. 1: this doesn't work: returns null, not array():
        foreach ($prop->parameters['NONEXIST'] as $param) echo "$param\n";

        // ex. 2: this doesn't work: returns null, not array():
        foreach ($prop->offsetGet('NONEXIST') as $param) echo "$param\n";

        // this works, but is ugly:
        if ($prop->offsetExists('NONEXIST')) {
                foreach ($prop->offsetGet('NONEXIST') as $param) echo "$param\n";
        }

        // ex. 3: this is what we would like to do, but can't:
        foreach ($prop->select('NONEXIST') as $param) echo "$param\n";
}

To make ex. 1 and ex. 2 work correctly, we need to insert extra guard statements to check for null. What we would like to do is ex. 3: a select() with the same semantics as Sabre\VObject\Component::select(), but for parameters.

I think that adding select() would make the API more symmetrical, and would discourage the use of the offsetGet() family, which apart from being poorly named, duplicates the functionality of $parameters and add().

Multiple types for telephone

Is there an easy way to pull back multiple types for tel?

Something like this, only pulls back the first:

foreach($this->_vcard->TEL as $tel) {
echo $tel['TYPE'] . ' : ' . $tel . "\n";
}

If I var dump the object $tel, I can see them in parameters?

Thanks
Tom

Wrong timezone detection

This file imports one hour too late:

BEGIN:VCALENDAR
METHOD:REQUEST
PRODID:Microsoft Exchange Server 2010
VERSION:2.0
BEGIN:VTIMEZONE
TZID:Central Standard Time
BEGIN:STANDARD
DTSTART:16010101T020000
TZOFFSETFROM:-0500
TZOFFSETTO:-0600
RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:16010101T020000
TZOFFSETFROM:-0600
TZOFFSETTO:-0500
RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
ORGANIZER;CN=
ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=:MAILTO:
ATTACH:CID:
ATTACH:CID:
DESCRIPTION;LANGUAGE=en-US:When: Monday, March 25, 2013 1:30 PM-2:00 PM.
(UTC-06:00) Central Time (US & Canada)\nWhere: Dial-in: ;Pa
sscode: \n\n__~_~_~\n\n\nHi all,\n\nPlease join us fo
r the kick-off call Monday, 3/2
5/2013, at 1:30pm CST. If there are any schedule conflicts, please do no
t hesitate to contact me. Attached are the Thank you!\n\nU
nited States: \n\n * Conference Room Number: \n
nted copies.\n
SUMMARY;LANGUAGE=en-US:KICK-OFF CALL: s
tudy
DTSTART;TZID=Central Standard Time:20130325T133000
DTEND;TZID=Central Standard Time:20130325T140000
UID:
CLASS:PUBLIC
PRIORITY:5
DTSTAMP:20130322T220602Z
TRANSP:OPAQUE
STATUS:CONFIRMED
SEQUENCE:0
LOCATION;LANGUAGE=en-US:Dial-in: ;Passcode:
X-MICROSOFT-CDO-APPT-SEQUENCE:0
X-MICROSOFT-CDO-OWNERAPPTID:
X-MICROSOFT-CDO-BUSYSTATUS:TENTATIVE
X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY
X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
X-MICROSOFT-CDO-IMPORTANCE:1
X-MICROSOFT-CDO-INSTTYPE:0
X-MICROSOFT-DISALLOW-COUNTER:FALSE
BEGIN:VALARM
ACTION:DISPLAY
DESCRIPTION:REMINDER
TRIGGER;RELATED=START:-PT15M
END:VALARM
END:VEVENT
END:VCALENDAR

BUG with recurrence events with exclusions

I have an recurrenct event with exclusions:

img_0079

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Sabre//Sabre VObject 3.1.3//EN
CALSCALE:GREGORIAN
BEGIN:VEVENT
SEQUENCE:1
TRANSP:OPAQUE
DTSTAMP:20130820T085947Z
UID:8258a4fc-0eab-4ba7-8bda-b8dac8568830
DTSTART;VALUE=DATE:20130820
DTEND;VALUE=DATE:20130821
SUMMARY:000
DESCRIPTION:
LOCATION:
RRULE:FREQ=DAILY;INTERVAL=1;UNTIL=20130821T200000Z
LAST-MODIFIED:20130820T090004Z
END:VEVENT
BEGIN:VEVENT
SEQUENCE:1
TRANSP:OPAQUE
RECURRENCE-ID:20130820T000000Z
LAST-MODIFIED:20130820T090004Z
UID:8258a4fc-0eab-4ba7-8bda-b8dac8568830
DTSTART;VALUE=DATE:20130820
DTEND;VALUE=DATE:20130821
SUMMARY:000-0
DESCRIPTION:
LOCATION:
END:VEVENT
END:VCALENDAR

after using VCalendar::expand method:

img_0080

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Sabre//Sabre VObject 3.1.3//EN
CALSCALE:GREGORIAN
BEGIN:VEVENT
SEQUENCE:1
TRANSP:OPAQUE
DTSTAMP:20130820T085947Z
UID:8258a4fc-0eab-4ba7-8bda-b8dac8568830
DTSTART;VALUE=DATE:20130820
DTEND;VALUE=DATE:20130821
SUMMARY:000
DESCRIPTION:
LOCATION:
LAST-MODIFIED:20130820T090004Z
END:VEVENT
BEGIN:VEVENT
SEQUENCE:1
TRANSP:OPAQUE
DTSTAMP:20130820T085947Z
UID:8258a4fc-0eab-4ba7-8bda-b8dac8568830
DTSTART;VALUE=DATE:20130821
DTEND;VALUE=DATE:20130822
SUMMARY:000
DESCRIPTION:
LOCATION:
LAST-MODIFIED:20130820T090004Z
RECURRENCE-ID:20130821T000000Z
END:VEVENT
END:VCALENDAR

Properties containing \r

Example code:

$prop = new \Sabre\VObject\Property('test', "abc\r\ndef");
echo $prop->serialize();

Result: \ndefabc
Expected: TEST:abc\ndef or TEST:abc\r\ndef, i'm not sure…

Incorrect getValue() for multiple parameters with same key

Observed in Sabre-VObject 3.0.0-alpha4. Received the following (anonymized) string from client (OS X Contacts.app):

ADR;type=HOME;type=pref:;;Main Street;Littleville;Arizona;AAA999;Denmark

Converted this into a parameter object called $addr. Trying to loop over the type parameters:

$types = $addr->offsetGet('TYPE');
foreach ($types as $type) {
  echo $type->getValue() . "\n";
}

Expected output:

HOME
pref

Actual output:

HOME,pref

I expect the output of $types->getValue() to be the stringified value of all parameters that share the same key (HOME,pref), but the output of $type->getValue() to be the stringified value of just that parameter (HOME, then pref).

The workaround is an extra foreach ($type->getParts() as $part), but that shouldn't be necessary.

What about adding a component for VTIMEZONE?

Hi, all

Just a question to clarify stuff that's not documented ...

I found out quite soon, while trying to port a iCalcreator implementation to this library, that there is no definition for VTIMEZONE creation.

When does a VTIMEZONE component get added to a calendar? Is this based on which VEVENTs I add and the timezone in their start- or endtime, or is it based on something else?

Bye
Simon

Not possible to set SORT-AS property according to RFC

According to RFC 6350, section 5.9, the SORT-AS parameter in a vCard-4.0 looks something like this:

N;SORT-AS="Harten,Rene":van der Harten;Rene,J.;Sir;R.D.O.N.

Let's try to replicate this example in Sabre-VObject 3.0.0-alpha4:

<?php

include('lib/SabreDAV/vendor/autoload.php');

use Sabre\VObject;

$card = new VObject\Component\VCard();
$card->add('N', array('van der Harten', array('Rene','J.'),'Sir','R.D.O.N.'), array('SORT-AS' => array('Harten','Rene')));

echo $card->serialize();

PHP spews a warning:

Warning: strtr() expects parameter 1 to be string, array given in (filename)

Sabre-VObject does not allow us to set multiple values per name component as specified in RFC 2426. Alright, try plain strings instead:

<?php

include('lib/SabreDAV/vendor/autoload.php');

use Sabre\VObject;

$card = new VObject\Component\VCard();
$card->add('N', array('van der Harten','Rene,J.','Sir','R.D.O.N.'), array('SORT-AS' => 'Harten,Rene'));

echo $card->serialize();

Output:

BEGIN:VCARD
VERSION:3.0
PRODID:-//Sabre//Sabre VObject 3.0.0-alpha4//EN
N;SORT-AS=Harten,Rene:van der Harten;Rene\,J.;Sir;R.D.O.N.
END:VCARD

Inconsistency: the comma in the property value is escaped, but not in the parameter value.

According to the RFC, the SORT-AS value should be surrounded by double quotes. Since Sabre-VObject does not add them for us, let's try to force them by including them in the value:

<?php

include('lib/SabreDAV/vendor/autoload.php');

use Sabre\VObject;

$card = new VObject\Component\VCard();
$card->add('N', array('van der Harten','Rene,J.','Sir','R.D.O.N.'), array('SORT-AS' => '"Harten,Rene"'));

echo $card->serialize();

The output, not surprisingly, escapes the double quotes:

BEGIN:VCARD
VERSION:3.0
PRODID:-//Sabre//Sabre VObject 3.0.0-alpha4//EN
N;SORT-AS="^'Harten,Rene^'":van der Harten;Rene\,J.;Sir;R.D.O.N.
END:VCARD

And so it seems impossible to generate the SORT-AS parameter with escaped components and unescaped double quotes like the canonical example in the RFC.

Endless loop

Not a very big problem, but if you read an invalid vobject that has BEGIN: in it but no END:

It will loop forever in:

while(strtoupper(substr($nextLine,0,4))!=="END:") {

in static private function readLine.

Excluded event shows on another date

I have an event:

BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
BEGIN:VEVENT
SEQUENCE:1
TRANSP:OPAQUE
DTSTAMP;VALUE=DATE-TIME:20130729T070158Z
UID:ce6da6ae-2698-42d3-8266-161c44abdb4b
DTSTART;VALUE=DATE-TIME:20130711T050000Z
DTEND;VALUE=DATE-TIME:20130711T053000Z
SUMMARY:rep
DESCRIPTION:
LOCATION:
RRULE:FREQ=DAILY;INTERVAL=1;COUNT=2
LAST-MODIFIED;VALUE=DATE-TIME:20130729T070229Z
END:VEVENT
BEGIN:VEVENT
SEQUENCE:1
TRANSP:OPAQUE
RECURRENCE-ID:20130712T050000Z
LAST-MODIFIED;VALUE=DATE-TIME:20130729T070229Z
UID:ce6da6ae-2698-42d3-8266-161c44abdb4b
DTSTART;VALUE=DATE-TIME:20130719T050000Z
DTEND;VALUE=DATE-TIME:20130719T053000Z
SUMMARY:rep
DESCRIPTION:
END:VEVENT
END:VCALENDAR

after use "expand" method:

BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
BEGIN:VEVENT
SEQUENCE:1
TRANSP:OPAQUE
DTSTAMP;VALUE=DATE-TIME:20130729T070158Z
UID:ce6da6ae-2698-42d3-8266-161c44abdb4b
DTSTART;VALUE=DATE-TIME:20130711T050000Z
DTEND;VALUE=DATE-TIME:20130711T053000Z
SUMMARY:rep
DESCRIPTION:
LOCATION:
LAST-MODIFIED;VALUE=DATE-TIME:20130729T070229Z
END:VEVENT
BEGIN:VEVENT
SEQUENCE:1
TRANSP:OPAQUE
DTSTAMP;VALUE=DATE-TIME:20130729T070158Z
UID:ce6da6ae-2698-42d3-8266-161c44abdb4b
DTSTART;VALUE=DATE-TIME:20130713T050000Z
DTEND;VALUE=DATE-TIME:20130713T053000Z
SUMMARY:rep
DESCRIPTION:
LOCATION:
LAST-MODIFIED;VALUE=DATE-TIME:20130729T070229Z
RECURRENCE-ID:20130713T050000Z
END:VEVENT
END:VCALENDAR

Excluded event should be July 19, but it shows July 13.

VTODO

Just curious if anyone knows of apps out there that support VTODO? Neither Google Calendar nor Outlook seem to, which is a bit surprising.

Figured I'd post here and then update the docs based on what I learn.

Add support for FREQ=HOURLY;BYHOUR=8,9,10,11;BYDAY=SA,SU

Add support for FREQ=HOURLY;BYHOUR=8,9,10,11;BYDAY=SA,SU..

That will be every weekend between 8,9,10,11.. I have a pull requests ready, for this.. but will wait to submit until we are clear if my previous pull request was accepted..

Sabre Vobject can't parse ics generated by Deutsche Bahn

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);

Property\Text should handle CHARSET encoding for VCARD v2.1

Now that we finally have a Property::getValue() (hooray) that returns the value in a datatype native to PHP without all the base64/quoted-printable encoding fuzz, I think it should also support (de)encoding according to its CHARSET parameter. Specifically MS outlook (and very likely others) usually uses the native system encoding and includes this in the CHARSET declaration only once special characters (outside of the standard ASCII range?) are included in the property value.

Now that VObject v3 is right around the corner, I'd vote for including it before the feature freeze to avoid breaking the API once again.

I'll see if I can contribute some patches, but I wanted to post this right away.

VCalendar::expand method and lost event

$sData =
"BEGIN:VCALENDAR
CALSCALE:GREGORIAN
PRODID:-//Apple Inc.//iOS 6.1.4//EN
VERSION:2.0
BEGIN:VTIMEZONE
TZID:Europe/Moscow
BEGIN:DAYLIGHT
DTSTART:19930328T020000
RRULE:FREQ=YEARLY;UNTIL=20100327T230000Z;BYMONTH=3;BYDAY=-1SU
TZNAME:GMT+04:00
TZOFFSETFROM:+0300
TZOFFSETTO:+0400
END:DAYLIGHT
BEGIN:STANDARD
DTSTART:20110327T020000
RDATE:20110327T020000
TZNAME:GMT+04:00
TZOFFSETFROM:+0300
TZOFFSETTO:+0400
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
CREATED:20130710T065433Z
DTEND;TZID=Europe/Moscow:20130710T120000
DTSTAMP:20130710T065631Z
DTSTART;TZID=Europe/Moscow:20130710T110000
LAST-MODIFIED:20130710T065433Z
RRULE:FREQ=DAILY;UNTIL=20130712T195959Z
SEQUENCE:0
SUMMARY:Repeat
TRANSP:OPAQUE
UID:ED47E5D7-AB2B-4D77-9AF0-5CAEFB075A3A
END:VEVENT
BEGIN:VEVENT
CREATED:20130710T065630Z
DTEND;TZID=Europe/Moscow:20130713T120000
DTSTAMP:20130710T065631Z
DTSTART;TZID=Europe/Moscow:20130713T110000
LAST-MODIFIED:20130710T065630Z
RECURRENCE-ID;TZID=Europe/Moscow:20130711T110000
SEQUENCE:0
SUMMARY:Repeat
TRANSP:OPAQUE
UID:ED47E5D7-AB2B-4D77-9AF0-5CAEFB075A3A
END:VEVENT
END:VCALENDAR"

img_0026

$oVCal = \Sabre\VObject\Reader::read($sData );

$oVCal->expand(\Sabre\VObject\DateTimeParser::parse('20130630T000000Z'), \Sabre\VObject\DateTimeParser::parse('20130811T000000Z'));
$sData = $oVCal->serialize();

And after that:

$sData =
"BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
PRODID:-//Apple Inc.//iOS 6.1.4//EN
BEGIN:VEVENT
CREATED:20130710T065433Z
DTEND:20130710T080000Z
DTSTAMP:20130710T065631Z
DTSTART:20130710T070000Z
LAST-MODIFIED:20130710T065433Z
SEQUENCE:0
SUMMARY:Repeat
TRANSP:OPAQUE
UID:ED47E5D7-AB2B-4D77-9AF0-5CAEFB075A3A
END:VEVENT
BEGIN:VEVENT
CREATED:20130710T065433Z
DTEND:20130712T080000Z
DTSTAMP:20130710T065631Z
DTSTART:20130712T070000Z
LAST-MODIFIED:20130710T065433Z
SEQUENCE:0
SUMMARY:Repeat
TRANSP:OPAQUE
UID:ED47E5D7-AB2B-4D77-9AF0-5CAEFB075A3A
RECURRENCE-ID:20130712T110000Z
END:VEVENT
END:VCALENDAR"

Now event on 13th is not there.
Why the result has only 2 VEVENT objects?

Folded END-marker skipped in Splitter\VCard

Just a heads up, but the current implementation of Splitter\VCard does not cope with folded lines.

For example this VCard:

BEGIN:VCARD
VERSION:4.0
END:VCARD

Can be expressed (albeit unlikely) as:

BEGI
 N:VC
 ARD
VERS
 ION:
 4.0
END:
 VCAR
 D

Should probably be addressed by integrating the new parser, so it's likely related to ticket #31.

Method Sabre\VObject\Parameter::__toString() must return a string value

Possible bug in lib/Sabre/VObject/Parameter.php:

__toString is not allowed to return null, according to PHP documentation, but it calls getValue method which can return null, according to the method documentation.

How to reproduce:

$vcard = new VObject\Component\VCard();
$vcard->add('TEL', '', array('pref' => null));
echo $vcard->TEL['PREF']; // this calls __toString()

Expanding calendars removes events that have no master event

Given the following VEVENT:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Example Corp.//RoundCube CalDAV Client//EN
BEGIN:VEVENT
CREATED:20110305T003637Z
LAST-MODIFIED:20110305T003705Z
DTSTAMP:20110305T003705Z
UID:910fa9d0-b2a0-4c91-94f9-ccc088be7cae
SUMMARY:My birthsday
CATEGORIES:Birthday
TRANSP:TRANSPARENT
LOCATION:
DESCRIPTION:
DTSTART;VALUE=DATE:20140307
DURATION:P1D
RECURRENCE-ID;VALUE=DATE:20140307
END:VEVENT
END:VCALENDAR

Which is the result of the following calendar-query to a CalDAV server:

<?xml version="1.0" encoding="utf-8" ?>
<C:calendar-query xmlns:D="DAV:"
                  xmlns:C="urn:ietf:params:xml:ns:caldav">
  <D:prop>
    <C:calendar-data>
    <C:expand start="20140101T000000Z"
                       end="20140401T000000Z"/>
    </C:calendar-data>
    <D:getetag/>
  </D:prop>
  <C:filter>
    <C:comp-filter name="VCALENDAR">
      <C:comp-filter name="VEVENT">
        <C:time-range start="20140101T000000Z"
                             end="20140401T000000Z"/>
      </C:comp-filter>
    </C:comp-filter>
  </C:filter>
</C:calendar-query>

In the above query we are requesting the CalDAV server to expand recurring events to the given time-range which is a perfectly normal ting to do.

Calling the method 'getBaseComponents' will return an empty array due to this statement:
if (isset($component->{'RECURRENCE-ID'}))
continue;

If the above statement is commented out everything works as expected.

How can i parse all VALARM on a VEVENT?

You can add more then one VALARM to a VEVENT, is it possible to parse all VALARMS with vobject?
Example File:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:ownCloud Calendar
BEGIN:VEVENT
CREATED:20140411T102715Z
UID:c3ba807264
LAST-MODIFIED:20140411T142457Z
DTSTAMP:20140411T142457Z
SUMMARY:xool.
DTSTART;TZID=Europe/Berlin:20140411T093000
DTEND;TZID=Europe/Berlin:20140411T150000
CLASS:PUBLIC
BEGIN:VALARM
TRIGGER:-PT15M
DESCRIPTION:owncloud
ACTION:DISPLAY
END:VALARM
BEGIN:VALARM
TRIGGER:-PT30M
DESCRIPTION:owncloud
ACTION:DISPLAY
END:VALARM
END:VEVENT
END:VCALENDAR

Thanks in advance

Failed to parse duplicate field names

Lightning is doing something like this for categories:

CATEGORIES:Category 1
CATEGORIES:Category 2

instead of

CATEGORIES:Category 1,Category 2

VObject parser version 2.x were able to decode the first version. VObject parser 3.x is not able to do this any more. Only the first category is returned.

Composer installation failing after move to fruux repo

I might be doing something wrong but I can't get composer to install sabre-vobject after it was moved to the new location

$ composer install
Loading composer repositories with package information
Installing dependencies                                                   
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested package fruux/sabre-vobject could not be found in any version, there may be a typo in the package name.
"require": {
        "fruux/sabre-vobject": "2.0.*"
    },

Expand not correctly when events not ordered

Take the following VCalendar:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN
BEGIN:VTIMEZONE
TZID:Europe/Brussels
X-LIC-LOCATION:Europe/Brussels
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
TZNAME:CEST
DTSTART:19700329T020000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
TZNAME:CET
DTSTART:19701025T030000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
CREATED:20130705T142510Z
LAST-MODIFIED:20130715T132556Z
DTSTAMP:20130715T132556Z
UID:1aef0b27-3d92-4581-829a-11999dd36724
SUMMARY:Werken
RRULE:FREQ=DAILY;COUNT=5
DTSTART;TZID=Europe/Brussels:20130715T090000
DTEND;TZID=Europe/Brussels:20130715T170000
LOCATION:Job
DESCRIPTION:Vrij
X-MOZ-GENERATION:9
END:VEVENT
BEGIN:VEVENT
CREATED:20130715T081654Z
LAST-MODIFIED:20130715T110931Z
DTSTAMP:20130715T110931Z
UID:1aef0b27-3d92-4581-829a-11999dd36724
SUMMARY:Werken
RECURRENCE-ID;TZID=Europe/Brussels:20130719T090000
DTSTART;TZID=Europe/Brussels:20130719T070000
DTEND;TZID=Europe/Brussels:20130719T150000
SEQUENCE:1
LOCATION:Job
DESCRIPTION:Vrij
X-MOZ-GENERATION:1
END:VEVENT
BEGIN:VEVENT
CREATED:20130715T111654Z
LAST-MODIFIED:20130715T132556Z
DTSTAMP:20130715T132556Z
UID:1aef0b27-3d92-4581-829a-11999dd36724
SUMMARY:Werken
RECURRENCE-ID;TZID=Europe/Brussels:20130716T090000
DTSTART;TZID=Europe/Brussels:20130716T070000
DTEND;TZID=Europe/Brussels:20130716T150000
SEQUENCE:1
LOCATION:Job
X-MOZ-GENERATION:2
END:VEVENT
BEGIN:VEVENT
CREATED:20130715T125942Z
LAST-MODIFIED:20130715T130023Z
DTSTAMP:20130715T130023Z
UID:1aef0b27-3d92-4581-829a-11999dd36724
SUMMARY:Werken
RECURRENCE-ID;TZID=Europe/Brussels:20130717T090000
DTSTART;TZID=Europe/Brussels:20130717T070000
DTEND;TZID=Europe/Brussels:20130717T150000
SEQUENCE:1
LOCATION:Job
X-MOZ-GENERATION:3
END:VEVENT
BEGIN:VEVENT
CREATED:20130715T130024Z
LAST-MODIFIED:20130715T130034Z
DTSTAMP:20130715T130034Z
UID:1aef0b27-3d92-4581-829a-11999dd36724
SUMMARY:Werken
RECURRENCE-ID;TZID=Europe/Brussels:20130718T090000
DTSTART;TZID=Europe/Brussels:20130718T090000
DTEND;TZID=Europe/Brussels:20130718T170000
LOCATION:Job
X-MOZ-GENERATION:5
DESCRIPTION:Vrij
END:VEVENT
END:VCALENDAR

Now if you expand this:

<?php

require_once 'vendor/autoload.php';
$data = file_get_contents('test.ics');
$object = Sabre\VObject\Reader::read($data);

$start = new DateTime('01-01-' . date('Y') . ' 00:00:00', new DateTimeZone('UTC'));
$start->modify('-5 years');
$end = new DateTime('31-12-' . date('Y') . ' 23:59:59', new DateTimeZone('UTC'));
$end->modify('+5 years');

$expanded = $object->expand($start, $end);

?>

Then you get a completely wrong result.
It gives you VEVENT's on
20130715
20130719
20130720
20130721
20130722

This is not correct, but due to the unordered VEVENT's this is the result of the expand.
If you order the VEVENT's correctly, you get the correct output:
20130715
20130716
20130717
20130718
20130719

Hope this can be fixed as this is quite annoying (using sabreDav in owncloud :))

If the first event is deleted it still shows up on recurring expansion

When the first event in a recurring series is in the exdate list and I expand the series of events, the events will still be listed in the element list. Here is a simple ical which should illustrate the issue:

BEGIN:VCALENDAR
BEGIN:VEVENT
DTSTART:20140117T073000Z
DTEND:20140117T083000Z
RRULE:FREQ=WEEKLY;BYDAY=TU;INTERVAL=1;UNTIL=20140319T235900Z
UID:a0fd324402f181769bf3f2b4bed17d82
SUMMARY:rec test
DTSTAMP:20140119T142008Z
DESCRIPTION:
X-ALT-DESC;FMTTYPE=text/html:
EXDATE:20140117T073000Z
ORGANIZER:Super User
END:VEVENT
END:VCALENDAR

Wrong timezone detection

What version of the product are you using? What client software are you
using?
1.8.2

You import timezones based on the magic number in X-MICROSOFT-CDO-TZID:
http://msdn.microsoft.com/en-us/library/aa563018(loband).aspx

As you can see the value 2 is used for both Europe/Lisbon and Europe/Zagreb etc. Those timezones are different and I got one with zagreb in it and it's off by one hour :(

I hope you can find a way to fix this.

Thanks!

vObject 3.0 todo

Todo:

  • Change parser to deserialize multiple values
  • Property::toString
  • Parameter::serialize does not deal with arrays
  • Splitters should use streams
  • Ability to create a component with a magic setter.
  • 100% unittest coverage
  • Simplify array access for Parameters. Since they are now indexed by key, a lot of code can be scrapped.
  • Go over all vCard 2.1 properties and map them.
  • Go over all vCard 3.0 properties and map them.
  • Go over all vCard 4.0 properties and map them.
  • Go over all iCalendar 2.0 properties and map them.
  • Automatically prime new calendars and vcards with default properties.
  • Allow \DateTime values to be set using setValue()
  • Properly test DateTime properties. I suspect that it's broken for some vCard formats.
  • Uri needs better serializer/deserializer that doesn't do any escaping.
  • Some default value-types have changed in vCard 4. We need to change propertyMap to something that be overridden per vCard versions.
  • Issue #40
  • Issue #39
  • Changing properties from DATE-TIME to DATE as reported on the mailing list

Endless loop BYDAY=0TH

Expected behaviour

Sabre-VObject should throw an exception if the rrule data is invalid

Actual behaviour

It results in an endless loop

Example:

<?php
require_once('lib/Sabre/VObject/includes.php');

date_default_timezone_set('Europe/Berlin');

$input = <<<ICAL
BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
BEGIN:VEVENT
CREATED;VALUE=DATE-TIME:20140321T232924Z
UID:58192ee17f
RRULE:FREQ=MONTHLY;BYDAY=0TH;INTERVAL=1;UNTIL=20150101
LAST-MODIFIED;VALUE=DATE-TIME:20140321T232924Z
DTSTAMP;VALUE=DATE-TIME:20140321T232924Z
SUMMARY:Testevent
DTSTART;VALUE=DATE:20140306
DTEND;VALUE=DATE:20140309
END:VEVENT
END:VCALENDAR
ICAL;

$ics = Sabre\VObject\Reader::read($input);
$ics->expand(new DateTime('2014-01-01'), new DateTime('2014-12-31'));

Suppress warning

Can we suppres this warning?

PHP Warning: DateTimeZone::__construct() [datetimezone.--construct]: Unknown or bad timezone (E. South America Standard Time) in /opt/go/go/vendor/VObject/lib/Sabre/VObject/TimeZoneUtil.php on line 412

I know normally error suppression is bad but in this case if you look at the code it can be wise because I have many of these messages in the logs and they are not really errors.

Excessive escaping of Compound properties

I'm unsure whether this should end up in #19, but there's a related escaping problem in the serialization of vCard's ADR field.
I create the property like this:

$tmp = new Property\Compound('ADR', '', array());
$tmp->setParts(array($i->PoBox, $i->ExtAddress, $i->Address, $i->City, $i->Province, $i->Cap, $i->Nation));
$vCard->add($tmp);

Imagine $i->Address contains "Street Name, 15"
In Compound::setParts() the comma will be escaped: "Street Name, 15"
In Property::serialize() the slash will be escaped: "Street Name, 15"

Now, since comma is not the delimiter for ADR, why is it escaped at all in Compound::setParts()?
Can $delimiterMap be used to determine the correct delimiter that needs to be escaped or am i missing something?
Here's the patch i'm currently using to workaround this problem:

Index: sabre/vobject/lib/Sabre/VObject/Property/Compound.php
===================================================================
--- sabre/vobject/lib/Sabre/VObject/Property/Compound.php   (revision 2158)
+++ sabre/vobject/lib/Sabre/VObject/Property/Compound.php   (working copy)
@@ -76,10 +76,13 @@
         $compoundValues = preg_split("/(?<!\\\)$delimiter/", $this->value);

         // remove slashes from any semicolon and comma left escaped in the single values
-        $compoundValues = array_map(
-            function($val) {
-                return strtr($val, array('\,' => ',', '\;' => ';'));
-        }, $compoundValues);
+        array_walk(
+            $compoundValues,
+            function($val, $idx, $delimiter) {
+                return strtr($val, array('\\'.$delimiter => $delimiter));
+            },
+            $this->getDelimiter()
+        );

         return $compoundValues;

@@ -115,11 +118,15 @@
     public function setParts(array $values) {

         // add slashes to all semicolons and commas in the single values
-        $values = array_map(
-            function($val) {
-                return strtr($val, array(',' => '\,', ';' => '\;'));
-            }, $values);

+        array_walk(
+            $values,
+            function($val, $idx, $delimiter) {
+                return strtr($val, array($delimiter => '\\'.$delimiter));
+            }, 
+            $this->getDelimiter()
+        );
+
         $this->setValue(
             implode($this->getDelimiter(), $values)
         );

Parameter Type Serializer Escaping Issue

Hi everybody,

I am facing some problems with ownCloud 4.5.7. My aim is to synchronise my N900 with ownCloud. On the N900 I am using syncevolution as synchronisation engine.

After doing a two-way sync all specific information is lost. For example telephone numbers are stripped of the information if they are cell, work, and so on. This will only happen during a two way sync, as on a one-way import the data is imported and displayed in ownCloud correctly. Problem is getting it back to the device.

So I came up with CURL just to see what is exported by ownCloud. For TEL it is exported as:

TEL;TYPE=HOME\,VOICE:...

But it should be:

TEL;TYPE=HOME,VOICE:...

By escaping comma the value list "HOME", "VOICE" is made a single value "HOME,VOICE". As an effect syncevolution refuses to parse the unknown value and omits/dumps the information.

For reference the relevant sections of RFC2426 (as ownCloud exports VCARD v3):

2.5 Structured Type Values

...

   Lists of values are delimited by a list delimiter, specified by the
   COMMA character (ASCII decimal 44). A COMMA character in a value MUST
   be escaped with a BACKSLASH character (ASCII decimal 92).

and


3.4.  Property Value Escaping

   Some properties may contain one or more values delimited by a COMMA
   character (U+002C).  Therefore, a COMMA character in a value MUST be
   escaped with a BACKSLASH character (U+005C), even for properties that
   don't allow multiple instances (for consistency).

...

   Furthermore, some fields of compound properties may contain a list of
   values delimited by a COMMA character.  Therefore, a COMMA character
   in one of a field's values MUST be escaped with a BACKSLASH
   character, even for fields that don't allow multiple values (for
   consistency).  Compound properties allowing multiple instances MUST
   NOT be encoded in a single content line.

...

   In all other cases, escaping MUST NOT be used.

So basically escaping ',' should not be used for elements on the left side of the colon.
I have not yet seen an example of "a COMMA character in a value".

Relevant code section is located in 3rdparty/Sabre/VObject/Parameter.php:66.
Disabling the comma escaping solves the issue for, but I am not quite sure about the side effects.

Please let me know your opinions on this as I am no expert on this topic.

Cheers,
Tempura

Property Serializer Escaping Issue

A property which requires comma or semi-colon escaping isn't being handled by the proerty serializer. For example:

$entry->description = 'this; and, then that';

gets pumped out as:

DESCRIPTION: this; and, then that

When it should be:

DESCRIPTION: this\; and\, then that

To add to the problem, I can't manually escape my text, as that just results in my user generated backslashes being escaped:

$entry->description = addcslashes('this; and, then that', ',;');
DESCRIPTION: this\\; and\\, then that

To fix the problem, I changed the property serializer to use the same escape parameters as the parameter serializer (Property.php around line 176):

$src = array(
            '\\',
            "\n",
            ';',
            ',',
        );
        $out = array(
            '\\\\',
            '\n',
            '\;',
            '\,',
        );
        $str.=':' . str_replace($src, $out, $this->value);

That does it, but I'm not comfortable enough with the RCF to know if this has side effects when serializing other parameters.

Spaces coming out as %20

This is a bit strange, but when I do:

foreach ($this->_vcard->IMPP as $im) {
echo $im;
}

I'm getting %20 rather than spaces. Is this intended? Looks url escaped.

I've probably missed something obvious but couldn't find where this might be happening in the source.

Thanks
Tom

jCard support & Packagist

Can you tag this repo on Packagist with a jCard tag so it shows up when someone searches for that term?

Decoding of description with last character : fails

I think this problem also applies to other fields, but I discovered it with an description element.

If you have the following element:

DESCRIPTION:This is a descpription\nwith a linebreak and a ; , and :

the result of getValue() for this element will be empty. If you add another character after the last : getValue() will return the correct result.

Recurring event with frst event modified shows as two event

I created a recurring event using Thunderbird and modified the time for its first event. Thunderbird shows the event with only the first event with the modified time, but expanding the event using the vobject library shows two events for the first day with the modifed tme 1100 and the old time 1000.

Not sure if this is an error or that Thunderbird handles this differently.

Event data below. I've changed the UID code for this example.

BEGIN:VCALENDAR
PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN
VERSION:2.0
BEGIN:VTIMEZONE
TZID:Asia/Kolkata
X-LIC-LOCATION:Asia/Kolkata
BEGIN:STANDARD
TZOFFSETFROM:+0530
TZOFFSETTO:+0530
TZNAME:IST
DTSTART:19700101T000000
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
CREATED:20121202T121848Z
LAST-MODIFIED:20121202T163941Z
DTSTAMP:20121202T163941Z
UID:xxxxxx
SUMMARY:Finish Calendaring Code
RRULE:FREQ=WEEKLY
DTSTART;TZID=Asia/Kolkata:20121202T100000
DTEND;TZID=Asia/Kolkata:20121202T190000
X-MOZ-GENERATION:7
SEQUENCE:5
END:VEVENT
BEGIN:VEVENT
CREATED:20121202T163910Z
LAST-MODIFIED:20121202T163941Z
DTSTAMP:20121202T163941Z
UID:xxxxxx
SUMMARY:Finish Calendaring Code
RECURRENCE-ID;TZID=Asia/Kolkata:20121202T100000
DTSTART;TZID=Asia/Kolkata:20121202T110000
DTEND;TZID=Asia/Kolkata:20121202T200000
SEQUENCE:6
X-MOZ-GENERATION:7
END:VEVENT
END:VCALENDAR

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.