Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions js/src/javascript/tokenizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,9 @@ function unescape_string(s) {
} else if (escaped === 0x22 || escaped === 0x27 || escaped === 0x5c) {
// single-quote, apostrophe, backslash - escape these
out += '\\' + String.fromCharCode(escaped);
} else if (escaped === 0x2028 || escaped === 0x2029 || escaped === 0xfeff) {
// U+2028 LINE SEPARATOR, U+2029 PARAGRAPH SEPARATOR, U+FEFF BOM are JavaScript line terminators, keep escaped so the output remains valid JS.
out += '\\' + matched[0];
} else {
out += String.fromCharCode(escaped);
}
Expand Down
3 changes: 3 additions & 0 deletions python/jsbeautifier/javascript/tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,9 @@ def unescape_string(self, s):
elif escaped == 0x22 or escaped == 0x27 or escaped == 0x5C:
# single-quote, apostrophe, backslash - escape these
out += "\\" + chr(escaped)
elif escaped in (0x2028, 0x2029, 0xFEFF):
# U+2028 LINE SEPARATOR, U+2029 PARAGRAPH SEPARATOR, U+FEFF BOM are JavaScript line terminators, keep escaped so the output remains valid JS.
out += "\\" + matched.group(0)
else:
out += self.acorn.six.unichr(escaped)

Expand Down