From 123a18e910f15816678171bf6854049ad402b6f9 Mon Sep 17 00:00:00 2001 From: "thakis@chromium.org" Date: Sun, 2 Feb 2014 16:17:12 +0000 Subject: [PATCH] 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 --- gyp_chromium | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gyp_chromium b/gyp_chromium index d05204b77..8713b4340 100755 --- a/gyp_chromium +++ b/gyp_chromium @@ -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):