From 8487afb44371c47afb3756908336b595ba7f4ffb Mon Sep 17 00:00:00 2001 From: Luis Cordova Date: Fri, 12 Apr 2013 09:43:46 -0500 Subject: [PATCH 1/4] 7644 add tests for passing number looking attributes as strings in XmlUtils::phpsize --- src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php | 8 ++++++++ src/Symfony/Component/Config/Util/XmlUtils.php | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php b/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php index a3d264e1891cc..2fcc0743741b7 100644 --- a/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php +++ b/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php @@ -118,6 +118,14 @@ public function getDataForPhpize() array(-120.0, '-1.2E2'), array(-10100.1, '-10100.1'), array(-10100.1, '-10,100.1'), + array('1234 5678 9101 1121 3141', '1234 5678 9101 1121 3141'), + array('1,2,3,4', '1,2,3,4'), + array('11,22,33,44', '11,22,33,44'), + array('11,222,333,4', '11,222,333,4'), + array(1222333444.0, '1,222,333,444'), + array(11222333444.0, '11,222,333,444'), + array(111222333444.0, '111,222,333,444'), + array('1111,2222,3333,4444,5555', '1111,2222,3333,4444,5555'), array('foo', 'foo'), ); } diff --git a/src/Symfony/Component/Config/Util/XmlUtils.php b/src/Symfony/Component/Config/Util/XmlUtils.php index 9317e15e7c771..2769d4020dad6 100644 --- a/src/Symfony/Component/Config/Util/XmlUtils.php +++ b/src/Symfony/Component/Config/Util/XmlUtils.php @@ -193,6 +193,10 @@ public static function phpize($value) return false; case is_numeric($value): return '0x' == $value[0].$value[1] ? hexdec($value) : floatval($value); + case preg_match('/^[0-9]{1,3}(,[0-9]{3})+?$/', $value): + return floatval(str_replace(',', '', $value)); + case preg_match('/^[0-9]+(,[0-9]+)+?$/', $value): + return $value; case preg_match('/^(-|\+)?[0-9,]+(\.[0-9]+)?$/', $value): return floatval(str_replace(',', '', $value)); default: From 7d4a4156c2980914e34d3fa4be2b3b4884afc1f1 Mon Sep 17 00:00:00 2001 From: Luis Cordova Date: Sat, 13 Apr 2013 20:27:30 -0500 Subject: [PATCH 2/4] if it has commas then it is a string --- src/Symfony/Component/Config/Util/XmlUtils.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/Config/Util/XmlUtils.php b/src/Symfony/Component/Config/Util/XmlUtils.php index 2769d4020dad6..2e9d86ec21676 100644 --- a/src/Symfony/Component/Config/Util/XmlUtils.php +++ b/src/Symfony/Component/Config/Util/XmlUtils.php @@ -193,12 +193,8 @@ public static function phpize($value) return false; case is_numeric($value): return '0x' == $value[0].$value[1] ? hexdec($value) : floatval($value); - case preg_match('/^[0-9]{1,3}(,[0-9]{3})+?$/', $value): - return floatval(str_replace(',', '', $value)); - case preg_match('/^[0-9]+(,[0-9]+)+?$/', $value): - return $value; - case preg_match('/^(-|\+)?[0-9,]+(\.[0-9]+)?$/', $value): - return floatval(str_replace(',', '', $value)); + case preg_match('/^(-|\+)?[0-9]+(\.[0-9]+)?$/', $value): + return floatval($value); default: return $value; } From 447029c4ed3ae7040434f7dfb7b09c15fff2fbb1 Mon Sep 17 00:00:00 2001 From: Luis Cordova Date: Sat, 13 Apr 2013 20:38:24 -0500 Subject: [PATCH 3/4] update tests --- src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php b/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php index 2fcc0743741b7..feb796b68f379 100644 --- a/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php +++ b/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php @@ -117,14 +117,14 @@ public function getDataForPhpize() array(100.0, '1e2'), array(-120.0, '-1.2E2'), array(-10100.1, '-10100.1'), - array(-10100.1, '-10,100.1'), + array('-10,100.1', '-10,100.1'), array('1234 5678 9101 1121 3141', '1234 5678 9101 1121 3141'), array('1,2,3,4', '1,2,3,4'), array('11,22,33,44', '11,22,33,44'), array('11,222,333,4', '11,222,333,4'), - array(1222333444.0, '1,222,333,444'), - array(11222333444.0, '11,222,333,444'), - array(111222333444.0, '111,222,333,444'), + array('1,222,333,444', '1,222,333,444'), + array('11,222,333,444', '11,222,333,444'), + array('111,222,333,444', '111,222,333,444'), array('1111,2222,3333,4444,5555', '1111,2222,3333,4444,5555'), array('foo', 'foo'), ); From 634b6c24d963f06cf460625dc3ab43b79faacab9 Mon Sep 17 00:00:00 2001 From: Luis Cordova Date: Sat, 13 Apr 2013 21:14:51 -0500 Subject: [PATCH 4/4] update value 1,000.3 --- .../DependencyInjection/Tests/Fixtures/xml/services2.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services2.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services2.xml index bada1c892fb0f..6e8a6ce364dce 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services2.xml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services2.xml @@ -16,7 +16,7 @@ on off 1.3 - 1,000.3 + 1000.3 a string foo