[Pkg-owncloud-commits] [php-sabre-vobject] 09/38: When a parameter value contains +, quote the value.

David Prévot taffit at moszumanska.debian.org
Tue Sep 23 03:10:21 UTC 2014


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

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

commit d1ae21c50bf705eb09bca360bbe32b44b295f0c1
Author: Evert Pot <evert at rooftopsolutions.nl>
Date:   Mon Sep 15 18:07:17 2014 +0100

    When a parameter value contains +, quote the value.
---
 lib/Parameter.php               | 18 ++++++++++++++++--
 tests/VObject/ParameterTest.php | 14 ++++++++++++++
 2 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/lib/Parameter.php b/lib/Parameter.php
index 9750d78..ca91019 100644
--- a/lib/Parameter.php
+++ b/lib/Parameter.php
@@ -287,8 +287,22 @@ class Parameter extends Node {
                 if (!is_null($out)) $out.=',';
 
                 // If there's no special characters in the string, we'll use the simple
-                // format
-                if (!preg_match('#(?: [\n":;\^,] )#x', $item)) {
+                // format.
+                //
+                // The list of special characters is defined as:
+                //
+                // Any character except CONTROL, DQUOTE, ";", ":", ","
+                //
+                // by the iCalendar spec:
+                // https://tools.ietf.org/html/rfc5545#section-3.1
+                //
+                // And we add ^ to that because of:
+                // https://tools.ietf.org/html/rfc6868
+                //
+                // But we've found that iCal (7.0, shipped with OSX 10.9)
+                // severaly trips on + characters not  being quoted, so we
+                // added + as well.
+                if (!preg_match('#(?: [\n":;\^,\+] )#x', $item)) {
                     return $out.$item;
                 } else {
                     // Enclosing in double-quotes, and using RFC6868 for encoding any
diff --git a/tests/VObject/ParameterTest.php b/tests/VObject/ParameterTest.php
index 2e2629c..2aabd0e 100644
--- a/tests/VObject/ParameterTest.php
+++ b/tests/VObject/ParameterTest.php
@@ -87,6 +87,20 @@ class ParameterTest extends \PHPUnit_Framework_TestCase {
 
     }
 
+    /**
+     * iCal 7.0 (OSX 10.9) has major issues with the EMAIL property, when the
+     * value contains a plus sign, and it's not quoted.
+     *
+     * So we specifically added support for that.
+     */
+    function testSerializePlusSign() {
+
+        $cal = new Component\VCalendar();
+        $param = new Parameter($cal, 'EMAIL',"user+something at example.org");
+        $this->assertEquals('EMAIL="user+something at example.org"',$param->serialize());
+
+    }
+
     function testIterate() {
 
         $cal = new Component\VCalendar();

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