[Pkg-owncloud-commits] [php-sabre-vobject] 03/65: Fix double-escaping of , and ; in compound properties

David Prévot taffit at moszumanska.debian.org
Tue Feb 24 23:57:11 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository php-sabre-vobject.

commit fa16e574e230d794292b8d9bfcb2e05175a72704
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date:   Mon Jan 12 20:41:25 2015 +0100

    Fix double-escaping of , and ; in compound properties
---
 lib/Sabre/VObject/Property.php                |  9 +++++++++
 tests/Sabre/VObject/Property/CompoundTest.php | 15 +++++++++++++++
 tests/Sabre/VObject/PropertyTest.php          |  8 ++++++++
 3 files changed, 32 insertions(+)

diff --git a/lib/Sabre/VObject/Property.php b/lib/Sabre/VObject/Property.php
index 84a6094..d9cc255 100644
--- a/lib/Sabre/VObject/Property.php
+++ b/lib/Sabre/VObject/Property.php
@@ -195,6 +195,15 @@ class Property extends Node {
             '\n',
             '',
         );
+
+        // avoid double-escaping of \, and \; from Compound properties
+        if (method_exists($this, 'setParts')) {
+            $src[] = '\\\\,';
+            $out[] = '\\,';
+            $src[] = '\\\\;';
+            $out[] = '\\;';
+        }
+
         $str.=':' . str_replace($src, $out, $this->value);
 
         $out = '';
diff --git a/tests/Sabre/VObject/Property/CompoundTest.php b/tests/Sabre/VObject/Property/CompoundTest.php
index 5d8cdaa..58185c4 100644
--- a/tests/Sabre/VObject/Property/CompoundTest.php
+++ b/tests/Sabre/VObject/Property/CompoundTest.php
@@ -56,4 +56,19 @@ class CompoundTest extends \PHPUnit_Framework_TestCase {
         $this->assertEquals(0, count($elem->getParts()));
 
     }
+
+    function testSerialize() {
+
+        $arr = array(
+            'ABC, Inc.',
+            'North American Division',
+            'Marketing;Sales',
+        );
+
+        $elem = new Compound('ORG');
+        $elem->setParts($arr);
+
+        $this->assertEquals("ORG:ABC\, Inc.;North American Division;Marketing\;Sales\r\n", $elem->serialize());
+
+    }
 }
diff --git a/tests/Sabre/VObject/PropertyTest.php b/tests/Sabre/VObject/PropertyTest.php
index 3bb2895..0e1bc60 100644
--- a/tests/Sabre/VObject/PropertyTest.php
+++ b/tests/Sabre/VObject/PropertyTest.php
@@ -169,6 +169,14 @@ class PropertyTest extends \PHPUnit_Framework_TestCase {
 
     }
 
+    public function testSerializeEscape() {
+
+        $property = new Property('propname','propvalue\escaped');
+
+        $this->assertEquals("PROPNAME:propvalue\\\\escaped\r\n",$property->serialize());
+
+    }
+
     public function testSerializeLongLine() {
 
         $value = str_repeat('!',200);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabre-vobject.git



More information about the Pkg-owncloud-commits mailing list