Skip to content

Commit

Permalink
[jan] Fix unescaping of commas in ADR, N, and ORG attributes.
Browse files Browse the repository at this point in the history
  • Loading branch information
yunosh committed Jul 4, 2017
1 parent f79a6bd commit bc08448
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 6 deletions.
8 changes: 6 additions & 2 deletions framework/Icalendar/lib/Horde/Icalendar.php
Expand Up @@ -804,8 +804,12 @@ public function parsevCalendar($text, $base = 'VCALENDAR', $clear = true)

// Split by unescaped semicolons:
$values = preg_split('/(?<!\\\\);/', $value);
$value = str_replace('\\;', ';', $value);
$values = str_replace('\\;', ';', $values);
$value = str_replace(
array('\\;', '\\,'), array(';', ','), $value
);
$values = str_replace(
array('\\;', '\\,'), array(';', ','), $values
);
$this->setAttribute($tag, trim($value), $params, true, $values);
break;

Expand Down
12 changes: 8 additions & 4 deletions framework/Icalendar/package.xml
Expand Up @@ -23,7 +23,7 @@
<email>mrubinsk@horde.org</email>
<active>yes</active>
</developer>
<date>2017-03-20</date>
<date>2017-07-04</date>
<version>
<release>2.1.7</release>
<api>2.1.0</api>
Expand All @@ -34,7 +34,7 @@
</stability>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
*
* [jan] Fix unescaping of commas in ADR, N, and ORG attributes.
</notes>
<contents>
<dir baseinstalldir="/" name="/">
Expand Down Expand Up @@ -411,6 +411,8 @@
<file name="timezone3.ics" role="test" />
<file name="timezone4.ics" role="test" />
<file name="vcal20.ics" role="test" />
<file name="vcard2.1.vcs" role="test" />
<file name="vcard3.0.vcs" role="test" />
<file name="vfreebusy1.ics" role="test" />
<file name="vfreebusy2.ics" role="test" />
</dir> <!-- /test/Horde/Icalendar/fixtures -->
Expand Down Expand Up @@ -637,6 +639,8 @@
<install as="Horde/Icalendar/fixtures/timezone3.ics" name="test/Horde/Icalendar/fixtures/timezone3.ics" />
<install as="Horde/Icalendar/fixtures/timezone4.ics" name="test/Horde/Icalendar/fixtures/timezone4.ics" />
<install as="Horde/Icalendar/fixtures/vcal20.ics" name="test/Horde/Icalendar/fixtures/vcal20.ics" />
<install as="Horde/Icalendar/fixtures/vcard2.1.vcs" name="test/Horde/Icalendar/fixtures/vcard2.1.vcs" />
<install as="Horde/Icalendar/fixtures/vcard3.0.vcs" name="test/Horde/Icalendar/fixtures/vcard3.0.vcs" />
<install as="Horde/Icalendar/fixtures/vfreebusy1.ics" name="test/Horde/Icalendar/fixtures/vfreebusy1.ics" />
<install as="Horde/Icalendar/fixtures/vfreebusy2.ics" name="test/Horde/Icalendar/fixtures/vfreebusy2.ics" />
<install as="Horde/Icalendar/fixtures/vTimezone/allcategories.ics" name="test/Horde/Icalendar/fixtures/vTimezone/allcategories.ics" />
Expand Down Expand Up @@ -1286,10 +1290,10 @@ Lots of improvements, bugfixes and support for more fields and members of the iC
<stability>
<release>stable</release>
<api>stable</api></stability>
<date>2017-03-20</date>
<date>2017-07-04</date>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
*
* [jan] Fix unescaping of commas in ADR, N, and ORG attributes.
</notes>
</release>
</changelog>
Expand Down
28 changes: 28 additions & 0 deletions framework/Icalendar/test/Horde/Icalendar/ExportTest.php
Expand Up @@ -139,6 +139,34 @@ public function testEscapes()
array('There are important words after this dash - see anything here or have the words gone?'),
$readIcal->getComponent(1)->getAttributeValues('DESCRIPTION')
);

foreach (array('2.1', '3.0') as $version) {
$contact = new Horde_Icalendar_Vcard($version);
$contact->setAttribute(
'N', null, array(), true, array('Contact', 'Test')
);
$contact->setAttribute('FN', 'Test,Contact');
$contact->setAttribute(
'ORG', null, array(), true, array('My,Company', 'IT Department')
);
$this->assertStringEqualsFile(
__DIR__ . '/fixtures/vcard' . $version . '.vcs',
$contact->exportVcalendar()
);
$readIcal = new Horde_Icalendar();
$readIcal->parseVCalendar($contact->exportVCalendar());
$vcard = $readIcal->getComponent(0);
$this->assertEquals(
array('Contact', 'Test'), $vcard->getAttributeValues('N')
);
$this->assertEquals(
array('Test,Contact'), $vcard->getAttributeValues('FN')
);
$this->assertEquals(
array('My,Company', 'IT Department'),
$vcard->getAttributeValues('ORG')
);
}
}

public function testQuotedParameters()
Expand Down
@@ -0,0 +1,6 @@
BEGIN:VCARD
VERSION:2.1
N:Contact;Test
FN:Test,Contact
ORG:My,Company;IT Department
END:VCARD
@@ -0,0 +1,6 @@
BEGIN:VCARD
VERSION:3.0
N:Contact;Test
FN:Test\,Contact
ORG:My\,Company;IT Department
END:VCARD

0 comments on commit bc08448

Please sign in to comment.