Skip to content

Commit ae07cb1

Browse files
gorhillmarijnh
authored andcommitted
[search addon] Escape sequence only for \n, \r, \t and \\
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
1 parent f454d57 commit ae07cb1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

addon/search/search.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,12 @@
7878
}
7979

8080
function parseString(string) {
81-
return string.replace(/\\(.)/g, function(_, ch) {
81+
return string.replace(/\\([nrt\\])/g, function(match, ch) {
8282
if (ch == "n") return "\n"
8383
if (ch == "r") return "\r"
84-
return ch
84+
if (ch == "t") return "\t"
85+
if (ch == "\\") return "\\"
86+
return match
8587
})
8688
}
8789

0 commit comments

Comments
 (0)