[Pkg-owncloud-commits] [php-sabre-vobject] 12/19: repair was unable to do its job for iCalendar objects.

David Prévot taffit at moszumanska.debian.org
Sun Jun 15 02:08:54 UTC 2014


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 f9889bb0f3458df1e732f2c2d8c8b3f01b973690
Author: Evert Pot <me at evertpot.com>
Date:   Thu Jun 5 13:02:43 2014 -0400

    repair was unable to do its job for iCalendar objects.
---
 lib/Sabre/VObject/Component/VCalendar.php |  2 +-
 lib/Sabre/VObject/Property.php            |  6 ++++--
 lib/Sabre/VObject/StringUtil.php          | 16 +++++++++++-----
 3 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/lib/Sabre/VObject/Component/VCalendar.php b/lib/Sabre/VObject/Component/VCalendar.php
index 3e000d5..7b7f628 100644
--- a/lib/Sabre/VObject/Component/VCalendar.php
+++ b/lib/Sabre/VObject/Component/VCalendar.php
@@ -329,7 +329,7 @@ class VCalendar extends VObject\Document {
      */
     public function validate($options = 0) {
 
-        $warnings = parent::validate();
+        $warnings = parent::validate($options);
 
         if ($ver = $this->VERSION) {
             if ((string)$ver !== '2.0') {
diff --git a/lib/Sabre/VObject/Property.php b/lib/Sabre/VObject/Property.php
index f85825b..ea606d3 100644
--- a/lib/Sabre/VObject/Property.php
+++ b/lib/Sabre/VObject/Property.php
@@ -466,16 +466,18 @@ abstract class Property extends Node {
             $level = 3;
             if ($options & self::REPAIR) {
                 $newValue = StringUtil::convertToUTF8($oldValue);
-                if (StringUtil::isUTF8($newValue)) {
+                if (true || StringUtil::isUTF8($newValue)) {
                     $this->setRawMimeDirValue($newValue);
                     $level = 1;
                 }
 
             }
 
-            $message = 'Property is not valid UTF-8!';
+
             if (preg_match('%([\x00-\x08\x0B-\x0C\x0E\x0F])%', $oldValue, $matches)) {
                 $message = 'Property contained a control character (0x' . bin2hex($matches[1]) . ')';
+            } else {
+                $message = 'Property is not valid UTF-8! ' . $oldValue;
             }
 
             $warnings[] = array(
diff --git a/lib/Sabre/VObject/StringUtil.php b/lib/Sabre/VObject/StringUtil.php
index 09e1980..2b64902 100644
--- a/lib/Sabre/VObject/StringUtil.php
+++ b/lib/Sabre/VObject/StringUtil.php
@@ -44,12 +44,18 @@ class StringUtil {
      */
     static function convertToUTF8($str) {
 
-        $encoding = mb_detect_encoding($str , array('UTF-8','ISO-8859-1'), true);
+        $encoding = mb_detect_encoding($str , array('UTF-8','ISO-8859-1', 'WINDOWS-1252'), true);
+
+        switch($encoding) {
+            case 'ISO-8859-1' :
+                $newStr = utf8_encode($str);
+                break;
+            case 'WINDOWS-1252' :
+                $newStr = iconv('cp1252', 'UTF-8', $str);
+                break;
+            default :
+                 $newStr = $str;
 
-        if ($encoding === 'ISO-8859-1') {
-            $newStr = utf8_encode($str);
-        } else {
-            $newStr = $str;
         }
 
         // Removing any control characters

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