New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(codegen): fix unicode escaping in es5 #3636
Merged
kdy1
merged 12 commits into
swc-project:main
from
williamtetlow:fix-unicode-escaping-in-es5
Feb 25, 2022
Merged
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d9433ff
fix unicode escpaing in es5
williamtetlow b6b4ce2
replicate same logic as babel
williamtetlow 3bba63f
fix tests and generate surrogates
williamtetlow 88befb4
add unit tests for escape_without_source
williamtetlow b4e469c
Merge branch 'main' into fix-unicode-escaping-in-es5
williamtetlow da40f01
revert change to 2257
williamtetlow e92cc06
add regression test for issue 3617
williamtetlow 287ec00
lazily initialize regex
williamtetlow fd31c41
remove debug log
williamtetlow 4a11bab
do string contains instead of regex
williamtetlow 0ef810b
remove unused crate
williamtetlow 3931123
Merge branch 'main' into fix-unicode-escaping-in-es5
swc-bot File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
crates/swc/tests/tsc-references/templateStringWhitespaceEscapes2_ES6_es5.1.normal.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
//@target: es6 | ||
// <TAB>, <VT>, <FF>, <SP>, <NBSP>, <BOM> | ||
"\t\v\f \xa0"; | ||
"\t\v\f \xa0\uFEFF"; |
2 changes: 1 addition & 1 deletion
2
crates/swc/tests/tsc-references/templateStringWhitespaceEscapes2_es5.1.normal.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
// <TAB>, <VT>, <FF>, <SP>, <NBSP>, <BOM> | ||
"\t\v\f \xa0"; | ||
"\t\v\f \xa0\uFEFF"; |
2 changes: 1 addition & 1 deletion
2
crates/swc/tests/tsc-references/unicodeExtendedEscapesInStrings06_ES5_es5.1.normal.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// @target: es5 | ||
// ES6 Spec - 10.1.1 Static Semantics: UTF16Encoding (cp) | ||
// 1. Assert: 0 ≤ cp ≤ 0x10FFFF. | ||
var x = ""; | ||
var x = "\uDBFF\uDFFF"; |
2 changes: 1 addition & 1 deletion
2
crates/swc/tests/tsc-references/unicodeExtendedEscapesInStrings06_ES6_es5.1.normal.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// @target: es6 | ||
// ES6 Spec - 10.1.1 Static Semantics: UTF16Encoding (cp) | ||
// 1. Assert: 0 ≤ cp ≤ 0x10FFFF. | ||
var x = ""; | ||
var x = "\uDBFF\uDFFF"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
crates/swc/tests/tsc-references/unicodeExtendedEscapesInStrings13_ES5_es5.1.normal.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
// @target: es5 | ||
var x = ""; | ||
var x = "\uDB37\uDDDD"; |
2 changes: 1 addition & 1 deletion
2
crates/swc/tests/tsc-references/unicodeExtendedEscapesInStrings13_ES6_es5.1.normal.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
// @target: es6 | ||
var x = ""; | ||
var x = "\uDB37\uDDDD"; |
2 changes: 1 addition & 1 deletion
2
crates/swc/tests/tsc-references/unicodeExtendedEscapesInStrings15_ES5_es5.1.normal.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
// @target: es5 | ||
var x = "ꯍ㑖碐"; | ||
var x = "\uABCD\uEF12\u3456\u7890"; |
2 changes: 1 addition & 1 deletion
2
crates/swc/tests/tsc-references/unicodeExtendedEscapesInStrings15_ES6_es5.1.normal.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
// @target: es6 | ||
var x = "ꯍ㑖碐"; | ||
var x = "\uABCD\uEF12\u3456\u7890"; |
2 changes: 1 addition & 1 deletion
2
crates/swc/tests/tsc-references/unicodeExtendedEscapesInStrings16_ES5_es5.1.normal.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
// @target: es5 | ||
var x = "ꯍ㑖碐"; | ||
var x = "\uABCD\uEF12\u3456\u7890"; |
2 changes: 1 addition & 1 deletion
2
crates/swc/tests/tsc-references/unicodeExtendedEscapesInStrings16_ES6_es5.1.normal.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
// @target: es6 | ||
var x = "ꯍ㑖碐"; | ||
var x = "\uABCD\uEF12\u3456\u7890"; |
2 changes: 1 addition & 1 deletion
2
crates/swc/tests/tsc-references/unicodeExtendedEscapesInTemplates06_ES5_es5.1.normal.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// @target: es5 | ||
// ES6 Spec - 10.1.1 Static Semantics: UTF16Encoding (cp) | ||
// 1. Assert: 0 ≤ cp ≤ 0x10FFFF. | ||
var x = ""; | ||
var x = "\uDBFF\uDFFF"; |
2 changes: 1 addition & 1 deletion
2
crates/swc/tests/tsc-references/unicodeExtendedEscapesInTemplates06_ES6_es5.1.normal.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// @target: es6 | ||
// ES6 Spec - 10.1.1 Static Semantics: UTF16Encoding (cp) | ||
// 1. Assert: 0 ≤ cp ≤ 0x10FFFF. | ||
var x = ""; | ||
var x = "\uDBFF\uDFFF"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
crates/swc/tests/tsc-references/unicodeExtendedEscapesInTemplates13_ES5_es5.1.normal.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
// @target: es5 | ||
var x = ""; | ||
var x = "\uDB37\uDDDD"; |
2 changes: 1 addition & 1 deletion
2
crates/swc/tests/tsc-references/unicodeExtendedEscapesInTemplates13_ES6_es5.1.normal.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
// @target: es6 | ||
var x = ""; | ||
var x = "\uDB37\uDDDD"; |
2 changes: 1 addition & 1 deletion
2
crates/swc/tests/tsc-references/unicodeExtendedEscapesInTemplates15_ES5_es5.1.normal.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
// @target: es5 | ||
var x = "ꯍ㑖碐"; | ||
var x = "\uABCD\uEF12\u3456\u7890"; |
2 changes: 1 addition & 1 deletion
2
crates/swc/tests/tsc-references/unicodeExtendedEscapesInTemplates15_ES6_es5.1.normal.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
// @target: es6 | ||
var x = "ꯍ㑖碐"; | ||
var x = "\uABCD\uEF12\u3456\u7890"; |
2 changes: 1 addition & 1 deletion
2
crates/swc/tests/tsc-references/unicodeExtendedEscapesInTemplates16_ES5_es5.1.normal.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
// @target: es5 | ||
var x = "ꯍ㑖碐"; | ||
var x = "\uABCD\uEF12\u3456\u7890"; |
2 changes: 1 addition & 1 deletion
2
crates/swc/tests/tsc-references/unicodeExtendedEscapesInTemplates16_ES6_es5.1.normal.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
// @target: es6 | ||
var x = "ꯍ㑖碐"; | ||
var x = "\uABCD\uEF12\u3456\u7890"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setting this to
true
is equivalent to disablingjsesc
minimal
optionhttps://github.com/mathiasbynens/jsesc#minimal