Skip to content

Commit

Permalink
[search addon] Escape sequence only for \n, \r, \t and \\
Browse files Browse the repository at this point in the history
When `\` is followed by any other character, it will not be
interpreted as an escape sequence, i.e. `\3` will be
interpreted as literal `\3`, not as `3`.

Fixes #5428
  • Loading branch information
gorhill authored and marijnh committed Jul 7, 2019
1 parent f454d57 commit ae07cb1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions addon/search/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@
}

function parseString(string) {
return string.replace(/\\(.)/g, function(_, ch) {
return string.replace(/\\([nrt\\])/g, function(match, ch) {
if (ch == "n") return "\n"
if (ch == "r") return "\r"
return ch
if (ch == "t") return "\t"
if (ch == "\\") return "\\"
return match
})
}

Expand Down

0 comments on commit ae07cb1

Please sign in to comment.