Bug 1518026 - Escape '!' to '\041' in posix strings ($'...');r=Honza
authorBrian Grinstead <bgrinstead@mozilla.com>
Fri, 18 Jan 2019 14:52:35 +0000
changeset 511557 10d517464fb1ba1ea73ddcaea039e32f4f4116f6
parent 511556 3e975e4b35581bf59856f275d8fe56c7667d8b84
child 511558 ef8493b00486cefceab561b75c6a993cd7b8d19f
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersHonza
bugs1518026
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1518026 - Escape '!' to '\041' in posix strings ($'...');r=Honza Differential Revision: https://phabricator.services.mozilla.com/D16515
devtools/client/netmonitor/test/browser_net_curl-utils.js
devtools/client/shared/curl.js
--- a/devtools/client/netmonitor/test/browser_net_curl-utils.js
+++ b/devtools/client/netmonitor/test/browser_net_curl-utils.js
@@ -196,16 +196,20 @@ function testEscapeStringPosix() {
   is(CurlUtils.escapeStringPosix(surroundedWithQuotes), "'A simple string'",
     "The string should be surrounded with single quotes.");
 
   const singleQuotes = "It's unusual to put crickets in your coffee.";
   is(CurlUtils.escapeStringPosix(singleQuotes),
     "$'It\\'s unusual to put crickets in your coffee.'",
     "Single quotes should be escaped.");
 
+  const escapeChar = "\'!ls:q:gs|ls|;ping 8.8.8.8;|";
+  is(CurlUtils.escapeStringPosix(escapeChar), "$'\\'\\041ls:q:gs|ls|;ping 8.8.8.8;|'",
+    "'!' should be escaped.");
+
   const newLines = "Line 1\r\nLine 2\u000d\u000ALine3";
   is(CurlUtils.escapeStringPosix(newLines), "$'Line 1\\r\\nLine 2\\r\\nLine3'",
     "Newlines should be escaped.");
 
   const controlChars = "\u0007 \u0009 \u000C \u001B";
   is(CurlUtils.escapeStringPosix(controlChars), "$'\\x07 \\x09 \\x0c \\x1b'",
     "Control characters should be escaped.");
 
--- a/devtools/client/shared/curl.js
+++ b/devtools/client/shared/curl.js
@@ -357,16 +357,17 @@ const CurlUtils = {
     }
 
     if (/[^\x20-\x7E]|\'/.test(str)) {
       // Use ANSI-C quoting syntax.
       return "$\'" + str.replace(/\\/g, "\\\\")
                         .replace(/\'/g, "\\\'")
                         .replace(/\n/g, "\\n")
                         .replace(/\r/g, "\\r")
+                        .replace(/!/g, "\\041")
                         .replace(/[^\x20-\x7E]/g, escapeCharacter) + "'";
     }
 
     // Use single quote syntax.
     return "'" + str + "'";
   },
 
   /**