Merge pull request #8134 from alcohol/fix-8131

Fix 8131
main
Jordi Boggiano 5 years ago committed by GitHub
commit de8368af45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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* \} )

@ -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());
}
}

Loading…
Cancel
Save