Fix quoting of iCal property parameter values according to RFC 5545
Conflicts: plugins/libcalendaring/lib/Sabre/VObject/Parameter.php
This commit is contained in:
parent
708658043b
commit
cbe184364c
3 changed files with 12 additions and 10 deletions
|
@ -72,21 +72,19 @@ class Parameter extends Node {
|
||||||
$src = array(
|
$src = array(
|
||||||
'\\',
|
'\\',
|
||||||
"\n",
|
"\n",
|
||||||
';',
|
|
||||||
',',
|
|
||||||
);
|
);
|
||||||
$out = array(
|
$out = array(
|
||||||
'\\\\',
|
'\\\\',
|
||||||
'\n',
|
'\n',
|
||||||
'\;',
|
|
||||||
'\,',
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$value = str_replace($src, $out, $this->value);
|
// quote parameters according to RFC 5545, Section 3.2
|
||||||
if (strpos($value,":")!==false) {
|
$quotes = '';
|
||||||
$value = '"' . $value . '"';
|
if (preg_match('/[:;,]/', $this->value)) {
|
||||||
|
$quotes = '"';
|
||||||
}
|
}
|
||||||
return $this->name . '=' . $value;
|
|
||||||
|
return $this->name . '=' . $quotes . str_replace($src, $out, $this->value) . $quotes;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -263,6 +263,10 @@ class libvcalendar_test extends PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
$this->assertEquals("House, Street, Zip Place", $event['location'], "Decode escaped commas in location value");
|
$this->assertEquals("House, Street, Zip Place", $event['location'], "Decode escaped commas in location value");
|
||||||
$this->assertEquals("Me, meets Them\nThem, meet Me", $event['description'], "Decode description value");
|
$this->assertEquals("Me, meets Them\nThem, meet Me", $event['description'], "Decode description value");
|
||||||
|
$this->assertEquals("Kolab, Thomas", $event['attendees'][3]['name'], "Unescaped");
|
||||||
|
|
||||||
|
$ics = $ical->export($events);
|
||||||
|
$this->assertContains('ATTENDEE;CN="Kolab, Thomas";PARTSTAT=', $ics, "Quoted attendee parameters");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -9,9 +9,9 @@ ORGANIZER;CN="Organizor":MAILTO:organizor@example.org
|
||||||
DTSTAMP:20140225T160532Z
|
DTSTAMP:20140225T160532Z
|
||||||
ATTENDEE;CN="Master of Desaster";RSVP=TRUE;PARTSTAT=NEEDS-ACTION;
|
ATTENDEE;CN="Master of Desaster";RSVP=TRUE;PARTSTAT=NEEDS-ACTION;
|
||||||
ROLE=REQ-PARTICIPANT;X-UID=100156408:mailto:master@desaster.com
|
ROLE=REQ-PARTICIPANT;X-UID=100156408:mailto:master@desaster.com
|
||||||
ATTENDEE;CN="John Doe";RSVP=TRUE;PARTSTAT=NEEDS-ACTION;
|
ATTENDEE;CN="Doe, John";RSVP=TRUE;PARTSTAT=NEEDS-ACTION;
|
||||||
ROLE=REQ-PARTICIPANT;X-UID=115484392:mailto:doe@example.com
|
ROLE=REQ-PARTICIPANT;X-UID=115484392:mailto:doe@example.com
|
||||||
ATTENDEE;CN="Thomas Kolab";RSVP=TRUE;PARTSTAT=NEEDS-ACTION;
|
ATTENDEE;CN="Kolab\, Thomas";RSVP=TRUE;PARTSTAT=NEEDS-ACTION;
|
||||||
ROLE=REQ-PARTICIPANT;X-UID=115936264:mailto:thomas@kolab.org
|
ROLE=REQ-PARTICIPANT;X-UID=115936264:mailto:thomas@kolab.org
|
||||||
CREATED:20140225T160335Z
|
CREATED:20140225T160335Z
|
||||||
LAST-MODIFIED:20140225T160335Z
|
LAST-MODIFIED:20140225T160335Z
|
||||||
|
|
Loading…
Add table
Reference in a new issue