gn/gyp: Escape \ in addition to $ and " in strings.

BUG=340055
R=halyavin@google.com
TBR=brettw@chromium.org

Review URL: https://codereview.chromium.org/144573004

git-svn-id: http://src.chromium.org/svn/trunk/src/build@248410 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
This commit is contained in:
thakis@chromium.org 2014-02-02 16:17:12 +00:00
Родитель cbd4e06bee
Коммит 123a18e910
1 изменённых файлов: 3 добавлений и 2 удалений

Просмотреть файл

@ -77,8 +77,9 @@ def FormatKeyForGN(key):
def EscapeStringForGN(s):
"""Converts a string to a GN string literal."""
# Escape $ characters which have special meaning to GN.
return '"' + s.replace('$', '\\$').replace('"', '\\"') + '"'
for old, new in [('\\', '\\\\'), ('$', '\\$'), ('"', '\\"')]:
s = s.replace(old, new)
return '"' + s + '"'
def ProcessGypDefinesItems(items):