Skip to content

Commit

Permalink
Correctly parsing empty parameters now.
Browse files Browse the repository at this point in the history
  • Loading branch information
evert committed Feb 17, 2013

Verified

This commit was signed with the committer’s verified signature.
1 parent 3d3914d commit 03cac30
Showing 3 changed files with 22 additions and 14 deletions.
3 changes: 2 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
2.0.6-stable (2012-??-??)
2.0.6-stable (2013-02-17)
* Fixed: The reader now properly parses parameters without a value.

2.0.5-stable (2012-11-05)
* Fixed: The FreeBusyGenerator is now properly using the factory methods
30 changes: 18 additions & 12 deletions lib/Sabre/VObject/Reader.php
Original file line number Diff line number Diff line change
@@ -188,22 +188,28 @@ static private function readParameters($parameters) {
$params = array();
foreach($matches as $match) {

$value = isset($match['paramValue'])?$match['paramValue']:null;
if (!isset($match['paramValue'])) {

$value = null;

if (isset($value[0])) {
// Stripping quotes, if needed
if ($value[0] === '"') $value = substr($value,1,strlen($value)-2);
} else {
$value = '';
}

$value = preg_replace_callback('#(\\\\(\\\\|N|n|;|,))#',function($matches) {
if ($matches[2]==='n' || $matches[2]==='N') {
return "\n";
} else {
return $matches[2];
$value = $match['paramValue'];

if (isset($value[0]) && $value[0]==='"') {
// Stripping quotes, if needed
$value = substr($value,1,strlen($value)-2);
}
}, $value);

$value = preg_replace_callback('#(\\\\(\\\\|N|n|;|,))#',function($matches) {
if ($matches[2]==='n' || $matches[2]==='N') {
return "\n";
} else {
return $matches[2];
}
}, $value);

}

$params[] = new Parameter($match['paramName'], $value);

3 changes: 2 additions & 1 deletion tests/Sabre/VObject/ReaderTest.php
Original file line number Diff line number Diff line change
@@ -185,7 +185,8 @@ function testReadPropertyNoValue() {
$this->assertEquals('propValue', $result->value);
$this->assertEquals(1, count($result->parameters));
$this->assertEquals('PARAMNAME', $result->parameters[0]->name);
$this->assertEquals('', $result->parameters[0]->value);

$this->assertNull($result->parameters[0]->value);

}

0 comments on commit 03cac30

Please sign in to comment.