From 3a54cc50134806cc8e53abf0efa6faf416182990 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Thu, 15 Nov 2012 09:36:10 -0500
Subject: [PATCH] Fix rcube_utils::explode_quoted_string() with explode(), added tests

---
 program/include/rcube_utils.php |    2 +-
 tests/Framework/Utils.php       |   13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/program/include/rcube_utils.php b/program/include/rcube_utils.php
index 2a4d4c4..5cfd8e7 100644
--- a/program/include/rcube_utils.php
+++ b/program/include/rcube_utils.php
@@ -761,7 +761,7 @@
             }
         }
 
-        $result[] = substr($string, $p);
+        $result[] = (string) substr($string, $p);
 
         return $result;
     }
diff --git a/tests/Framework/Utils.php b/tests/Framework/Utils.php
index e588359..ec61c5d 100644
--- a/tests/Framework/Utils.php
+++ b/tests/Framework/Utils.php
@@ -193,4 +193,17 @@
         $mod = rcube_utils::mod_css_styles("background:\\0075\\0072\\006c( javascript:alert(&#039;xss&#039;) )", 'rcmbody');
         $this->assertEquals("/* evil! */", $mod, "Don't allow encoding quirks (2)");
     }
+
+    /**
+     * Check rcube_utils::explode_quoted_string() compat. with explode()
+     */
+    function test_explode_quoted_string_compat()
+    {
+        $data = array('', 'a,b,c', 'a', ',', ',a');
+
+        foreach ($data as $text) {
+            $result = rcube_utils::explode_quoted_string(',', $text);
+            $this->assertSame(explode(',', $text), $result);
+        }
+    }
 }

--
Gitblit v1.9.1