浏览代码

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