Преглед изворни кода

Clarify usage of addcslashes

Jordi Boggiano пре 12 година
родитељ
комит
20ef3e3c5b
1 измењених фајлова са 1 додато и 0 уклоњено
  1. 1 0
      src/Composer/Json/JsonManipulator.php

+ 1 - 0
src/Composer/Json/JsonManipulator.php

@@ -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)) {