Clarify usage of addcslashes
parent
3b48a1fea6
commit
20ef3e3c5b
|
@ -72,6 +72,7 @@ class JsonManipulator
|
||||||
if (isset($data[$type][$package])) {
|
if (isset($data[$type][$package])) {
|
||||||
// update existing link
|
// update existing link
|
||||||
$packageRegex = str_replace('/', '\\\\?/', preg_quote($package));
|
$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);
|
$links = preg_replace('{"'.$packageRegex.'"(\s*:\s*)'.self::$JSON_STRING.'}i', addcslashes(JsonFile::encode($package).'${1}"'.$constraint.'"', '\\'), $links);
|
||||||
} else {
|
} else {
|
||||||
if (preg_match('#^\s*\{\s*\S+.*?(\s*\}\s*)$#', $links, $match)) {
|
if (preg_match('#^\s*\{\s*\S+.*?(\s*\}\s*)$#', $links, $match)) {
|
||||||
|
|
Loading…
Reference in New Issue