1
0
Fork 0

Merge pull request #8134 from alcohol/fix-8131

Fix 8131
pull/8115/head
Jordi Boggiano 2019-05-08 15:58:52 +02:00 committed by GitHub
commit de8368af45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View File

@ -22,7 +22,7 @@ class JsonManipulator
private static $DEFINES = '(?(DEFINE)
(?<number> -? (?= [1-9]|0(?!\d) ) \d+ (\.\d+)? ([eE] [+-]? \d+)? )
(?<boolean> true | false | null )
(?<string> " ([^"\\\\]* | \\\\ ["\\\\bfnrt\/] | \\\\ u [0-9a-f]{4} )* " )
(?<string> " ([^"\\\\]* | \\\\ ["\\\\bfnrt\/] | \\\\ u [0-9A-Fa-f]{4} )* " )
(?<array> \[ (?: (?&json) \s* (?: , (?&json) \s* )* )? \s* \] )
(?<pair> \s* (?&string) \s* : (?&json) \s* )
(?<object> \{ (?: (?&pair) (?: , (?&pair) )* )? \s* \} )

View File

@ -2374,6 +2374,26 @@ class JsonManipulatorTest extends TestCase
"package/a": "*"
}
}
', $manipulator->getContents());
}
public function testEscapedUnicodeDoesNotCauseBacktrackLimitErrorGithubIssue8131()
{
$manipulator = new JsonManipulator('{
"description": "Some U\u00F1icode",
"require": {
"foo/bar": "^1.0"
}
}');
$this->assertTrue($manipulator->addLink('require', 'foo/baz', '^1.0'));
$this->assertEquals('{
"description": "Some U\u00F1icode",
"require": {
"foo/bar": "^1.0",
"foo/baz": "^1.0"
}
}
', $manipulator->getContents());
}
}