From c263f2141103cea18a1b7e48c62abf2617cc86a4 Mon Sep 17 00:00:00 2001 From: Ian Ricketson Date: Wed, 27 Dec 2023 09:02:24 -0700 Subject: [PATCH 1/3] Cast variable to string --- lib/util/sfToolkit.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/util/sfToolkit.class.php b/lib/util/sfToolkit.class.php index 543440ac0..03d17919a 100644 --- a/lib/util/sfToolkit.class.php +++ b/lib/util/sfToolkit.class.php @@ -254,7 +254,7 @@ public static function stringToArray($string) \s*(?: (?=\w+\s*=) | \s*$ # followed by another key= or the end of the string ) - /x', $string, $matches, PREG_SET_ORDER); + /x', (string) $string, $matches, PREG_SET_ORDER); $attributes = array(); foreach ($matches as $val) { From ee27c91c68a0a64ed34f72df2dba98eff3d8536d Mon Sep 17 00:00:00 2001 From: Ian Ricketson Date: Wed, 27 Dec 2023 09:27:50 -0700 Subject: [PATCH 2/3] Test for null --- test/unit/util/sfToolkitTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/unit/util/sfToolkitTest.php b/test/unit/util/sfToolkitTest.php index e40bfc308..51a9e13a5 100644 --- a/test/unit/util/sfToolkitTest.php +++ b/test/unit/util/sfToolkitTest.php @@ -10,11 +10,12 @@ require_once __DIR__.'/../../bootstrap/unit.php'; -$t = new lime_test(95); +$t = new lime_test(96); // ::stringToArray() $t->diag('::stringToArray()'); $tests = array( + null => array(), 'foo=bar' => array('foo' => 'bar'), 'foo1=bar1 foo=bar ' => array('foo1' => 'bar1', 'foo' => 'bar'), 'foo1="bar1 foo1"' => array('foo1' => 'bar1 foo1'), From a9a40abd8b00bda32b4a53f2ffaf4c903c0b55d2 Mon Sep 17 00:00:00 2001 From: Ian Ricketson Date: Wed, 27 Dec 2023 10:22:04 -0700 Subject: [PATCH 3/3] Fix test --- test/unit/util/sfToolkitTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/unit/util/sfToolkitTest.php b/test/unit/util/sfToolkitTest.php index 51a9e13a5..6e9032131 100644 --- a/test/unit/util/sfToolkitTest.php +++ b/test/unit/util/sfToolkitTest.php @@ -15,7 +15,6 @@ // ::stringToArray() $t->diag('::stringToArray()'); $tests = array( - null => array(), 'foo=bar' => array('foo' => 'bar'), 'foo1=bar1 foo=bar ' => array('foo1' => 'bar1', 'foo' => 'bar'), 'foo1="bar1 foo1"' => array('foo1' => 'bar1 foo1'), @@ -35,6 +34,8 @@ $t->is(sfToolkit::stringToArray($string), $attributes, '->stringToArray()'); } +$t->is(sfToolkit::stringToArray(null), array(), '->stringToArray() can accept a null value'); + // ::isUTF8() $t->diag('::isUTF8()'); $t->is(sfToolkit::isUTF8('été'), true, '::isUTF8() returns true if the parameter is an UTF-8 encoded string');