1
0
Fork 0

Clarify usage of addcslashes

pull/1887/merge
Jordi Boggiano 2013-05-12 22:59:28 +02:00
parent 3b48a1fea6
commit 20ef3e3c5b
1 changed files with 1 additions and 0 deletions

View File

@ -72,6 +72,7 @@ class JsonManipulator
if (isset($data[$type][$package])) {
// update existing link
$packageRegex = str_replace('/', '\\\\?/', preg_quote($package));
// addcslashes is used to double up backslashes since preg_replace resolves them as back references otherwise, see #1588
$links = preg_replace('{"'.$packageRegex.'"(\s*:\s*)'.self::$JSON_STRING.'}i', addcslashes(JsonFile::encode($package).'${1}"'.$constraint.'"', '\\'), $links);
} else {
if (preg_match('#^\s*\{\s*\S+.*?(\s*\}\s*)$#', $links, $match)) {