From f88970e20e6bfc3b49d8c4f60d21626f6ac79883 Mon Sep 17 00:00:00 2001 From: Dani Poroszkai Date: Thu, 22 Aug 2019 00:23:00 +0200 Subject: [PATCH] Add test case with control character The mox-worker item #3656 happens because there is a \x13 control character in the source map json. It happens when the angular-1.4.5.js source content is included in the source map, but strangely in the source map there is a \x13 character on the position where there is a \xe2\x80\x93 in the original source. In the test case I added a js source containing both characters, minified it by `uglifyjs control_character.js -m --source-map includeSources -o control_character.min.js` and load the source map as a json. It succeeds, because the minification escaped the control character properly. --- tests/fixtures/control_character.js | 5 +++++ tests/fixtures/control_character.min.js | 1 + tests/fixtures/control_character.min.map | 1 + tests/test_integration.py | 6 ++++++ 4 files changed, 13 insertions(+) create mode 100644 tests/fixtures/control_character.js create mode 100644 tests/fixtures/control_character.min.js create mode 100644 tests/fixtures/control_character.min.map diff --git a/tests/fixtures/control_character.js b/tests/fixtures/control_character.js new file mode 100644 index 0000000..e34b164 --- /dev/null +++ b/tests/fixtures/control_character.js @@ -0,0 +1,5 @@ +var x = 10; +if (x == 5) { + alert(''); + alert('–'); +} diff --git a/tests/fixtures/control_character.min.js b/tests/fixtures/control_character.min.js new file mode 100644 index 0000000..c0a7ffd --- /dev/null +++ b/tests/fixtures/control_character.min.js @@ -0,0 +1 @@ +var x=10;if(x==5){alert("");alert("–")} \ No newline at end of file diff --git a/tests/fixtures/control_character.min.map b/tests/fixtures/control_character.min.map new file mode 100644 index 0000000..a950e83 --- /dev/null +++ b/tests/fixtures/control_character.min.map @@ -0,0 +1 @@ +{"version":3,"sources":["control_character.js"],"names":["x","alert"],"mappings":"AAAA,IAAIA,EAAI,GACR,GAAIA,GAAK,EAAG,CACRC,MAAM,KACNA,MAAM","sourcesContent":["var x = 10;\nif (x == 5) {\n alert('\u0013');\n alert('–');\n}\n"]} \ No newline at end of file diff --git a/tests/test_integration.py b/tests/test_integration.py index 8755076..b406a34 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -65,3 +65,9 @@ def test_unicode_names(self): # This shouldn't blow up sourcemap.loads(min_map) + + def test_control_characters(self): + _, _, min_map = self.get_fixtures('control_character') + + # This shouldn't blow up + sourcemap.loads(min_map)