From 9ef06da310d49c8043d18e8f8313ad54505f156b Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Thu, 11 Jul 2019 09:50:12 -0400 Subject: [PATCH] Minor code review re. https://github.com/uBlockOrigin/uBlock-issues/issues/658 --- src/js/codemirror/search.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/js/codemirror/search.js b/src/js/codemirror/search.js index 2cb598db7..d21bd4c6d 100644 --- a/src/js/codemirror/search.js +++ b/src/js/codemirror/search.js @@ -163,12 +163,12 @@ // https://github.com/uBlockOrigin/uBlock-issues/issues/658 // Modified to backslash-escape ONLY widely-used control characters. function parseString(string) { - return string.replace(/\\(.)/g, function(_, ch) { - if (ch === "n") return "\n"; - if (ch === "r") return "\r"; - if (ch === 't') return '\t'; - if (ch === '\\') return '\\'; - return _; + return string.replace(/\\[nrt\\]/g, function(match) { + if (match === "\\n") return "\n"; + if (match === "\\r") return "\r"; + if (match === '\\t') return '\t'; + if (match === '\\\\') return '\\'; + return match; }); }