From bef89604e2f8d9660d221a44852a084840404189 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sat, 13 Dec 2014 14:31:19 +0000 Subject: [PATCH] Fix parsing of strings, fixes #3543 --- src/Composer/Json/JsonManipulator.php | 2 +- tests/Composer/Test/Json/JsonManipulatorTest.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Composer/Json/JsonManipulator.php b/src/Composer/Json/JsonManipulator.php index 751e9021e..e719e3d6d 100644 --- a/src/Composer/Json/JsonManipulator.php +++ b/src/Composer/Json/JsonManipulator.php @@ -31,7 +31,7 @@ class JsonManipulator if (!self::$RECURSE_BLOCKS) { self::$RECURSE_BLOCKS = '(?:[^{}]*|\{(?:[^{}]*|\{(?:[^{}]*|\{(?:[^{}]*|\{[^{}]*\})*\})*\})*\})*'; self::$RECURSE_ARRAYS = '(?:[^\]]*|\[(?:[^\]]*|\[(?:[^\]]*|\[(?:[^\]]*|\[[^\]]*\])*\])*\])*\]|'.self::$RECURSE_BLOCKS.')*'; - self::$JSON_STRING = '"(?:\\\\["bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4}|[^\0-\x09\x0a-\x1f\\\\"])+"'; + self::$JSON_STRING = '"(?:\\\\["bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4}|[^\0-\x09\x0a-\x1f\\\\"])*"'; self::$JSON_VALUE = '(?:[0-9.]+|null|true|false|'.self::$JSON_STRING.'|\['.self::$RECURSE_ARRAYS.'\]|\{'.self::$RECURSE_BLOCKS.'\})'; } diff --git a/tests/Composer/Test/Json/JsonManipulatorTest.php b/tests/Composer/Test/Json/JsonManipulatorTest.php index 7ffaaabc7..e3285efed 100644 --- a/tests/Composer/Test/Json/JsonManipulatorTest.php +++ b/tests/Composer/Test/Json/JsonManipulatorTest.php @@ -73,6 +73,7 @@ class JsonManipulatorTest extends \PHPUnit_Framework_TestCase ), array( '{ + "empty": "", "require": { "foo": "bar" } @@ -81,6 +82,7 @@ class JsonManipulatorTest extends \PHPUnit_Framework_TestCase 'vendor/baz', 'qux', '{ + "empty": "", "require": { "foo": "bar", "vendor/baz": "qux"