소스 검색

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