From dd1a6bee7b1b436113594d3de1b0fff37ea96eb6 Mon Sep 17 00:00:00 2001 From: Yuichiro Yamashita Date: Wed, 3 Jul 2024 13:37:56 +0900 Subject: [PATCH] fix: escape `%` if URI malformed (#5535) * fix: escape % if URI malformed * refactor: We recognize that decodeURIComponent exists in most of environment * revert sanitize-chunk-names test * fix: define internal functions to prevent being tree-shaken * add tests * add % to INVALID_CHAR_REGEX --------- Co-authored-by: Lukas Taegert-Atkinson --- src/utils/sanitizeFileName.ts | 2 +- .../sanitize-percent-encoding1/_config.js | 6 ++++ .../_expected/amd/main.js | 24 +++++++++++++++ .../_expected/cjs/main.js | 22 ++++++++++++++ .../_expected/es/main.js | 20 +++++++++++++ .../_expected/system/main.js | 29 +++++++++++++++++++ .../sanitize-percent-encoding1/foo%20bar.js | 3 ++ .../foo%E3%81%82bar.js | 3 ++ .../foo%E3%81bar.js | 3 ++ .../sanitize-percent-encoding1/foo%bar.js | 3 ++ .../sanitize-percent-encoding1/main.js | 9 ++++++ .../sanitize-percent-encoding2/_config.js | 6 ++++ .../_expected/amd/generated-foo_20bar.js | 5 ++++ .../amd/generated-foo_E3_81_82bar.js | 5 ++++ .../_expected/amd/generated-foo_E3_81bar.js | 5 ++++ .../_expected/amd/generated-foo_bar.js | 5 ++++ .../_expected/amd/main.js | 13 +++++++++ .../_expected/cjs/generated-foo_20bar.js | 3 ++ .../cjs/generated-foo_E3_81_82bar.js | 3 ++ .../_expected/cjs/generated-foo_E3_81bar.js | 3 ++ .../_expected/cjs/generated-foo_bar.js | 3 ++ .../_expected/cjs/main.js | 11 +++++++ .../_expected/es/generated-foo_20bar.js | 1 + .../_expected/es/generated-foo_E3_81_82bar.js | 1 + .../_expected/es/generated-foo_E3_81bar.js | 1 + .../_expected/es/generated-foo_bar.js | 1 + .../_expected/es/main.js | 6 ++++ .../_expected/system/generated-foo_20bar.js | 10 +++++++ .../system/generated-foo_E3_81_82bar.js | 10 +++++++ .../system/generated-foo_E3_81bar.js | 10 +++++++ .../_expected/system/generated-foo_bar.js | 10 +++++++ .../_expected/system/main.js | 13 +++++++++ .../sanitize-percent-encoding2/foo%20bar.js | 1 + .../foo%E3%81%82bar.js | 1 + .../foo%E3%81bar.js | 1 + .../sanitize-percent-encoding2/foo%bar.js | 1 + .../sanitize-percent-encoding2/main.js | 4 +++ .../sanitize-percent-encoding3/_config.js | 20 +++++++++++++ .../_expected/amd/foo_20bar.js | 7 +++++ .../_expected/amd/foo_E3_81_82bar.js | 7 +++++ .../_expected/amd/foo_E3_81bar.js | 7 +++++ .../_expected/amd/foo_bar.js | 7 +++++ .../_expected/cjs/foo_20bar.js | 5 ++++ .../_expected/cjs/foo_E3_81_82bar.js | 5 ++++ .../_expected/cjs/foo_E3_81bar.js | 5 ++++ .../_expected/cjs/foo_bar.js | 5 ++++ .../_expected/es/foo_20bar.js | 3 ++ .../_expected/es/foo_E3_81_82bar.js | 3 ++ .../_expected/es/foo_E3_81bar.js | 3 ++ .../_expected/es/foo_bar.js | 3 ++ .../_expected/system/foo_20bar.js | 10 +++++++ .../_expected/system/foo_E3_81_82bar.js | 10 +++++++ .../_expected/system/foo_E3_81bar.js | 10 +++++++ .../_expected/system/foo_bar.js | 10 +++++++ .../sanitize-percent-encoding3/main.js | 1 + .../file-references-in-bundle/_config.js | 4 +-- 56 files changed, 379 insertions(+), 3 deletions(-) create mode 100644 test/chunking-form/samples/sanitize-percent-encoding1/_config.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding1/_expected/amd/main.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding1/_expected/cjs/main.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding1/_expected/es/main.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding1/_expected/system/main.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding1/foo%20bar.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding1/foo%E3%81%82bar.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding1/foo%E3%81bar.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding1/foo%bar.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding1/main.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding2/_config.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding2/_expected/amd/generated-foo_20bar.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding2/_expected/amd/generated-foo_E3_81_82bar.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding2/_expected/amd/generated-foo_E3_81bar.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding2/_expected/amd/generated-foo_bar.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding2/_expected/amd/main.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding2/_expected/cjs/generated-foo_20bar.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding2/_expected/cjs/generated-foo_E3_81_82bar.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding2/_expected/cjs/generated-foo_E3_81bar.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding2/_expected/cjs/generated-foo_bar.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding2/_expected/cjs/main.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding2/_expected/es/generated-foo_20bar.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding2/_expected/es/generated-foo_E3_81_82bar.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding2/_expected/es/generated-foo_E3_81bar.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding2/_expected/es/generated-foo_bar.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding2/_expected/es/main.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding2/_expected/system/generated-foo_20bar.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding2/_expected/system/generated-foo_E3_81_82bar.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding2/_expected/system/generated-foo_E3_81bar.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding2/_expected/system/generated-foo_bar.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding2/_expected/system/main.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding2/foo%20bar.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding2/foo%E3%81%82bar.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding2/foo%E3%81bar.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding2/foo%bar.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding2/main.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding3/_config.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding3/_expected/amd/foo_20bar.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding3/_expected/amd/foo_E3_81_82bar.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding3/_expected/amd/foo_E3_81bar.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding3/_expected/amd/foo_bar.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding3/_expected/cjs/foo_20bar.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding3/_expected/cjs/foo_E3_81_82bar.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding3/_expected/cjs/foo_E3_81bar.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding3/_expected/cjs/foo_bar.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding3/_expected/es/foo_20bar.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding3/_expected/es/foo_E3_81_82bar.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding3/_expected/es/foo_E3_81bar.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding3/_expected/es/foo_bar.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding3/_expected/system/foo_20bar.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding3/_expected/system/foo_E3_81_82bar.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding3/_expected/system/foo_E3_81bar.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding3/_expected/system/foo_bar.js create mode 100644 test/chunking-form/samples/sanitize-percent-encoding3/main.js diff --git a/src/utils/sanitizeFileName.ts b/src/utils/sanitizeFileName.ts index 7997be993..c80ab56f7 100644 --- a/src/utils/sanitizeFileName.ts +++ b/src/utils/sanitizeFileName.ts @@ -1,6 +1,6 @@ // https://datatracker.ietf.org/doc/html/rfc2396 // eslint-disable-next-line no-control-regex -const INVALID_CHAR_REGEX = /[\u0000-\u001F"#$&*+,:;<=>?[\]^`{|}\u007F]/g; +const INVALID_CHAR_REGEX = /[\u0000-\u001F"#$%&*+,:;<=>?[\]^`{|}\u007F]/g; const DRIVE_LETTER_REGEX = /^[a-z]:/i; export function sanitizeFileName(name: string): string { diff --git a/test/chunking-form/samples/sanitize-percent-encoding1/_config.js b/test/chunking-form/samples/sanitize-percent-encoding1/_config.js new file mode 100644 index 000000000..7681012d0 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding1/_config.js @@ -0,0 +1,6 @@ +module.exports = defineTest({ + description: 'make sure illegal percent encoding is sanitized', + options: { + input: ['main.js'] + } +}); diff --git a/test/chunking-form/samples/sanitize-percent-encoding1/_expected/amd/main.js b/test/chunking-form/samples/sanitize-percent-encoding1/_expected/amd/main.js new file mode 100644 index 000000000..1d4ce3a6a --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding1/_expected/amd/main.js @@ -0,0 +1,24 @@ +define((function () { 'use strict'; + + function module1() { + console.log('foo%20bar'); + } + + function module2() { + console.log('foo%bar'); + } + + function module3() { + console.log('foo%E3%81%82bar'); + } + + function module4() { + console.log('foo%E3%81bar'); + } + + module1(); + module2(); + module3(); + module4(); + +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding1/_expected/cjs/main.js b/test/chunking-form/samples/sanitize-percent-encoding1/_expected/cjs/main.js new file mode 100644 index 000000000..a69739007 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding1/_expected/cjs/main.js @@ -0,0 +1,22 @@ +'use strict'; + +function module1() { + console.log('foo%20bar'); +} + +function module2() { + console.log('foo%bar'); +} + +function module3() { + console.log('foo%E3%81%82bar'); +} + +function module4() { + console.log('foo%E3%81bar'); +} + +module1(); +module2(); +module3(); +module4(); diff --git a/test/chunking-form/samples/sanitize-percent-encoding1/_expected/es/main.js b/test/chunking-form/samples/sanitize-percent-encoding1/_expected/es/main.js new file mode 100644 index 000000000..71c666568 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding1/_expected/es/main.js @@ -0,0 +1,20 @@ +function module1() { + console.log('foo%20bar'); +} + +function module2() { + console.log('foo%bar'); +} + +function module3() { + console.log('foo%E3%81%82bar'); +} + +function module4() { + console.log('foo%E3%81bar'); +} + +module1(); +module2(); +module3(); +module4(); diff --git a/test/chunking-form/samples/sanitize-percent-encoding1/_expected/system/main.js b/test/chunking-form/samples/sanitize-percent-encoding1/_expected/system/main.js new file mode 100644 index 000000000..b581ef787 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding1/_expected/system/main.js @@ -0,0 +1,29 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + function module1() { + console.log('foo%20bar'); + } + + function module2() { + console.log('foo%bar'); + } + + function module3() { + console.log('foo%E3%81%82bar'); + } + + function module4() { + console.log('foo%E3%81bar'); + } + + module1(); + module2(); + module3(); + module4(); + + }) + }; +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding1/foo%20bar.js b/test/chunking-form/samples/sanitize-percent-encoding1/foo%20bar.js new file mode 100644 index 000000000..62faaa1dc --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding1/foo%20bar.js @@ -0,0 +1,3 @@ +export function module1() { + console.log('foo%20bar'); +} diff --git a/test/chunking-form/samples/sanitize-percent-encoding1/foo%E3%81%82bar.js b/test/chunking-form/samples/sanitize-percent-encoding1/foo%E3%81%82bar.js new file mode 100644 index 000000000..394b0346b --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding1/foo%E3%81%82bar.js @@ -0,0 +1,3 @@ +export function module3() { + console.log('foo%E3%81%82bar'); +} diff --git a/test/chunking-form/samples/sanitize-percent-encoding1/foo%E3%81bar.js b/test/chunking-form/samples/sanitize-percent-encoding1/foo%E3%81bar.js new file mode 100644 index 000000000..0faac6203 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding1/foo%E3%81bar.js @@ -0,0 +1,3 @@ +export function module4() { + console.log('foo%E3%81bar'); +} diff --git a/test/chunking-form/samples/sanitize-percent-encoding1/foo%bar.js b/test/chunking-form/samples/sanitize-percent-encoding1/foo%bar.js new file mode 100644 index 000000000..7bf1be884 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding1/foo%bar.js @@ -0,0 +1,3 @@ +export function module2() { + console.log('foo%bar'); +} diff --git a/test/chunking-form/samples/sanitize-percent-encoding1/main.js b/test/chunking-form/samples/sanitize-percent-encoding1/main.js new file mode 100644 index 000000000..bd76f12e7 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding1/main.js @@ -0,0 +1,9 @@ +import { module1 } from './foo%20bar'; +import { module2 } from './foo%bar'; +import { module3 } from './foo%E3%81%82bar'; +import { module4 } from './foo%E3%81bar'; + +module1(); +module2(); +module3(); +module4(); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_config.js b/test/chunking-form/samples/sanitize-percent-encoding2/_config.js new file mode 100644 index 000000000..6a596f1ff --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_config.js @@ -0,0 +1,6 @@ +module.exports = defineTest({ + description: 'make sure illegal percent encoding is sanitized for dynamic imports', + options: { + input: ['main.js'] + } +}); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_expected/amd/generated-foo_20bar.js b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/amd/generated-foo_20bar.js new file mode 100644 index 000000000..d9b628c8a --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/amd/generated-foo_20bar.js @@ -0,0 +1,5 @@ +define((function () { 'use strict'; + + console.log('foo%20bar'); + +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_expected/amd/generated-foo_E3_81_82bar.js b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/amd/generated-foo_E3_81_82bar.js new file mode 100644 index 000000000..09260e1a1 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/amd/generated-foo_E3_81_82bar.js @@ -0,0 +1,5 @@ +define((function () { 'use strict'; + + console.log('foo%E3%81%82bar'); + +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_expected/amd/generated-foo_E3_81bar.js b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/amd/generated-foo_E3_81bar.js new file mode 100644 index 000000000..71aabe25b --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/amd/generated-foo_E3_81bar.js @@ -0,0 +1,5 @@ +define((function () { 'use strict'; + + console.log('foo%E3%81bar'); + +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_expected/amd/generated-foo_bar.js b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/amd/generated-foo_bar.js new file mode 100644 index 000000000..2aee12279 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/amd/generated-foo_bar.js @@ -0,0 +1,5 @@ +define((function () { 'use strict'; + + console.log('foo%bar'); + +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_expected/amd/main.js b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/amd/main.js new file mode 100644 index 000000000..d436cc2dd --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/amd/main.js @@ -0,0 +1,13 @@ +define(['require', 'exports'], (function (require, exports) { 'use strict'; + + const lazy1 = new Promise(function (resolve, reject) { require(['./generated-foo_20bar'], resolve, reject); }); + const lazy2 = new Promise(function (resolve, reject) { require(['./generated-foo_bar'], resolve, reject); }); + const lazy3 = new Promise(function (resolve, reject) { require(['./generated-foo_E3_81_82bar'], resolve, reject); }); + const lazy4 = new Promise(function (resolve, reject) { require(['./generated-foo_E3_81bar'], resolve, reject); }); + + exports.lazy1 = lazy1; + exports.lazy2 = lazy2; + exports.lazy3 = lazy3; + exports.lazy4 = lazy4; + +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_expected/cjs/generated-foo_20bar.js b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/cjs/generated-foo_20bar.js new file mode 100644 index 000000000..186700cae --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/cjs/generated-foo_20bar.js @@ -0,0 +1,3 @@ +'use strict'; + +console.log('foo%20bar'); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_expected/cjs/generated-foo_E3_81_82bar.js b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/cjs/generated-foo_E3_81_82bar.js new file mode 100644 index 000000000..8d5090778 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/cjs/generated-foo_E3_81_82bar.js @@ -0,0 +1,3 @@ +'use strict'; + +console.log('foo%E3%81%82bar'); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_expected/cjs/generated-foo_E3_81bar.js b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/cjs/generated-foo_E3_81bar.js new file mode 100644 index 000000000..acf063d90 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/cjs/generated-foo_E3_81bar.js @@ -0,0 +1,3 @@ +'use strict'; + +console.log('foo%E3%81bar'); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_expected/cjs/generated-foo_bar.js b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/cjs/generated-foo_bar.js new file mode 100644 index 000000000..5c05a1e81 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/cjs/generated-foo_bar.js @@ -0,0 +1,3 @@ +'use strict'; + +console.log('foo%bar'); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_expected/cjs/main.js b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/cjs/main.js new file mode 100644 index 000000000..c9b23f67f --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/cjs/main.js @@ -0,0 +1,11 @@ +'use strict'; + +const lazy1 = Promise.resolve().then(function () { return require('./generated-foo_20bar.js'); }); +const lazy2 = Promise.resolve().then(function () { return require('./generated-foo_bar.js'); }); +const lazy3 = Promise.resolve().then(function () { return require('./generated-foo_E3_81_82bar.js'); }); +const lazy4 = Promise.resolve().then(function () { return require('./generated-foo_E3_81bar.js'); }); + +exports.lazy1 = lazy1; +exports.lazy2 = lazy2; +exports.lazy3 = lazy3; +exports.lazy4 = lazy4; diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_expected/es/generated-foo_20bar.js b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/es/generated-foo_20bar.js new file mode 100644 index 000000000..522490d6c --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/es/generated-foo_20bar.js @@ -0,0 +1 @@ +console.log('foo%20bar'); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_expected/es/generated-foo_E3_81_82bar.js b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/es/generated-foo_E3_81_82bar.js new file mode 100644 index 000000000..20a52edef --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/es/generated-foo_E3_81_82bar.js @@ -0,0 +1 @@ +console.log('foo%E3%81%82bar'); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_expected/es/generated-foo_E3_81bar.js b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/es/generated-foo_E3_81bar.js new file mode 100644 index 000000000..790aefd8f --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/es/generated-foo_E3_81bar.js @@ -0,0 +1 @@ +console.log('foo%E3%81bar'); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_expected/es/generated-foo_bar.js b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/es/generated-foo_bar.js new file mode 100644 index 000000000..cc1acdddd --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/es/generated-foo_bar.js @@ -0,0 +1 @@ +console.log('foo%bar'); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_expected/es/main.js b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/es/main.js new file mode 100644 index 000000000..79aaf3404 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/es/main.js @@ -0,0 +1,6 @@ +const lazy1 = import('./generated-foo_20bar.js'); +const lazy2 = import('./generated-foo_bar.js'); +const lazy3 = import('./generated-foo_E3_81_82bar.js'); +const lazy4 = import('./generated-foo_E3_81bar.js'); + +export { lazy1, lazy2, lazy3, lazy4 }; diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_expected/system/generated-foo_20bar.js b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/system/generated-foo_20bar.js new file mode 100644 index 000000000..001206a01 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/system/generated-foo_20bar.js @@ -0,0 +1,10 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + console.log('foo%20bar'); + + }) + }; +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_expected/system/generated-foo_E3_81_82bar.js b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/system/generated-foo_E3_81_82bar.js new file mode 100644 index 000000000..b4c31ee01 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/system/generated-foo_E3_81_82bar.js @@ -0,0 +1,10 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + console.log('foo%E3%81%82bar'); + + }) + }; +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_expected/system/generated-foo_E3_81bar.js b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/system/generated-foo_E3_81bar.js new file mode 100644 index 000000000..f750c3ae9 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/system/generated-foo_E3_81bar.js @@ -0,0 +1,10 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + console.log('foo%E3%81bar'); + + }) + }; +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_expected/system/generated-foo_bar.js b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/system/generated-foo_bar.js new file mode 100644 index 000000000..b060386b1 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/system/generated-foo_bar.js @@ -0,0 +1,10 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + console.log('foo%bar'); + + }) + }; +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_expected/system/main.js b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/system/main.js new file mode 100644 index 000000000..2dc4c5dda --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/system/main.js @@ -0,0 +1,13 @@ +System.register([], (function (exports, module) { + 'use strict'; + return { + execute: (function () { + + const lazy1 = exports("lazy1", module.import('./generated-foo_20bar.js')); + const lazy2 = exports("lazy2", module.import('./generated-foo_bar.js')); + const lazy3 = exports("lazy3", module.import('./generated-foo_E3_81_82bar.js')); + const lazy4 = exports("lazy4", module.import('./generated-foo_E3_81bar.js')); + + }) + }; +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/foo%20bar.js b/test/chunking-form/samples/sanitize-percent-encoding2/foo%20bar.js new file mode 100644 index 000000000..522490d6c --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/foo%20bar.js @@ -0,0 +1 @@ +console.log('foo%20bar'); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/foo%E3%81%82bar.js b/test/chunking-form/samples/sanitize-percent-encoding2/foo%E3%81%82bar.js new file mode 100644 index 000000000..20a52edef --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/foo%E3%81%82bar.js @@ -0,0 +1 @@ +console.log('foo%E3%81%82bar'); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/foo%E3%81bar.js b/test/chunking-form/samples/sanitize-percent-encoding2/foo%E3%81bar.js new file mode 100644 index 000000000..790aefd8f --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/foo%E3%81bar.js @@ -0,0 +1 @@ +console.log('foo%E3%81bar'); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/foo%bar.js b/test/chunking-form/samples/sanitize-percent-encoding2/foo%bar.js new file mode 100644 index 000000000..cc1acdddd --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/foo%bar.js @@ -0,0 +1 @@ +console.log('foo%bar'); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/main.js b/test/chunking-form/samples/sanitize-percent-encoding2/main.js new file mode 100644 index 000000000..87093e4b8 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/main.js @@ -0,0 +1,4 @@ +export const lazy1 = import('./foo%20bar'); +export const lazy2 = import('./foo%bar'); +export const lazy3 = import('./foo%E3%81%82bar'); +export const lazy4 = import('./foo%E3%81bar'); diff --git a/test/chunking-form/samples/sanitize-percent-encoding3/_config.js b/test/chunking-form/samples/sanitize-percent-encoding3/_config.js new file mode 100644 index 000000000..52230552d --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding3/_config.js @@ -0,0 +1,20 @@ +module.exports = defineTest({ + description: 'make sure illegal percent encoding is sanitized for virtual entry points', + options: { + input: ['main'], + plugins: [ + { + options(options) { + options.input = ['foo%bar', 'foo%20bar', 'foo%E3%81%82bar', 'foo%E3%81bar']; + return options; + }, + resolveId(id) { + return id; + }, + load(id) { + return 'export default ' + JSON.stringify(id); + } + } + ] + } +}); diff --git a/test/chunking-form/samples/sanitize-percent-encoding3/_expected/amd/foo_20bar.js b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/amd/foo_20bar.js new file mode 100644 index 000000000..29f1883f9 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/amd/foo_20bar.js @@ -0,0 +1,7 @@ +define((function () { 'use strict'; + + var foo_20bar = "foo%20bar"; + + return foo_20bar; + +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding3/_expected/amd/foo_E3_81_82bar.js b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/amd/foo_E3_81_82bar.js new file mode 100644 index 000000000..7f23a1c35 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/amd/foo_E3_81_82bar.js @@ -0,0 +1,7 @@ +define((function () { 'use strict'; + + var foo_E3_81_82bar = "foo%E3%81%82bar"; + + return foo_E3_81_82bar; + +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding3/_expected/amd/foo_E3_81bar.js b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/amd/foo_E3_81bar.js new file mode 100644 index 000000000..301586187 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/amd/foo_E3_81bar.js @@ -0,0 +1,7 @@ +define((function () { 'use strict'; + + var foo_E3_81bar = "foo%E3%81bar"; + + return foo_E3_81bar; + +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding3/_expected/amd/foo_bar.js b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/amd/foo_bar.js new file mode 100644 index 000000000..292b7be9a --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/amd/foo_bar.js @@ -0,0 +1,7 @@ +define((function () { 'use strict'; + + var foo_bar = "foo%bar"; + + return foo_bar; + +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding3/_expected/cjs/foo_20bar.js b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/cjs/foo_20bar.js new file mode 100644 index 000000000..81775d75d --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/cjs/foo_20bar.js @@ -0,0 +1,5 @@ +'use strict'; + +var foo_20bar = "foo%20bar"; + +module.exports = foo_20bar; diff --git a/test/chunking-form/samples/sanitize-percent-encoding3/_expected/cjs/foo_E3_81_82bar.js b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/cjs/foo_E3_81_82bar.js new file mode 100644 index 000000000..5708ee7bb --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/cjs/foo_E3_81_82bar.js @@ -0,0 +1,5 @@ +'use strict'; + +var foo_E3_81_82bar = "foo%E3%81%82bar"; + +module.exports = foo_E3_81_82bar; diff --git a/test/chunking-form/samples/sanitize-percent-encoding3/_expected/cjs/foo_E3_81bar.js b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/cjs/foo_E3_81bar.js new file mode 100644 index 000000000..2b0ef97c1 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/cjs/foo_E3_81bar.js @@ -0,0 +1,5 @@ +'use strict'; + +var foo_E3_81bar = "foo%E3%81bar"; + +module.exports = foo_E3_81bar; diff --git a/test/chunking-form/samples/sanitize-percent-encoding3/_expected/cjs/foo_bar.js b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/cjs/foo_bar.js new file mode 100644 index 000000000..1a9eb2dda --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/cjs/foo_bar.js @@ -0,0 +1,5 @@ +'use strict'; + +var foo_bar = "foo%bar"; + +module.exports = foo_bar; diff --git a/test/chunking-form/samples/sanitize-percent-encoding3/_expected/es/foo_20bar.js b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/es/foo_20bar.js new file mode 100644 index 000000000..52120eeaa --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/es/foo_20bar.js @@ -0,0 +1,3 @@ +var foo_20bar = "foo%20bar"; + +export { foo_20bar as default }; diff --git a/test/chunking-form/samples/sanitize-percent-encoding3/_expected/es/foo_E3_81_82bar.js b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/es/foo_E3_81_82bar.js new file mode 100644 index 000000000..f5c8c225b --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/es/foo_E3_81_82bar.js @@ -0,0 +1,3 @@ +var foo_E3_81_82bar = "foo%E3%81%82bar"; + +export { foo_E3_81_82bar as default }; diff --git a/test/chunking-form/samples/sanitize-percent-encoding3/_expected/es/foo_E3_81bar.js b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/es/foo_E3_81bar.js new file mode 100644 index 000000000..0fefbf64a --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/es/foo_E3_81bar.js @@ -0,0 +1,3 @@ +var foo_E3_81bar = "foo%E3%81bar"; + +export { foo_E3_81bar as default }; diff --git a/test/chunking-form/samples/sanitize-percent-encoding3/_expected/es/foo_bar.js b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/es/foo_bar.js new file mode 100644 index 000000000..9634f9d87 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/es/foo_bar.js @@ -0,0 +1,3 @@ +var foo_bar = "foo%bar"; + +export { foo_bar as default }; diff --git a/test/chunking-form/samples/sanitize-percent-encoding3/_expected/system/foo_20bar.js b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/system/foo_20bar.js new file mode 100644 index 000000000..8e31ab663 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/system/foo_20bar.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + var foo_20bar = exports("default", "foo%20bar"); + + }) + }; +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding3/_expected/system/foo_E3_81_82bar.js b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/system/foo_E3_81_82bar.js new file mode 100644 index 000000000..0d0712f19 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/system/foo_E3_81_82bar.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + var foo_E3_81_82bar = exports("default", "foo%E3%81%82bar"); + + }) + }; +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding3/_expected/system/foo_E3_81bar.js b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/system/foo_E3_81bar.js new file mode 100644 index 000000000..6ff12d465 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/system/foo_E3_81bar.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + var foo_E3_81bar = exports("default", "foo%E3%81bar"); + + }) + }; +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding3/_expected/system/foo_bar.js b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/system/foo_bar.js new file mode 100644 index 000000000..202e15f9f --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/system/foo_bar.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + var foo_bar = exports("default", "foo%bar"); + + }) + }; +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding3/main.js b/test/chunking-form/samples/sanitize-percent-encoding3/main.js new file mode 100644 index 000000000..c0b933d7b --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding3/main.js @@ -0,0 +1 @@ +console.log('main'); diff --git a/test/function/samples/emit-file/file-references-in-bundle/_config.js b/test/function/samples/emit-file/file-references-in-bundle/_config.js index 815c35b56..21e2ff675 100644 --- a/test/function/samples/emit-file/file-references-in-bundle/_config.js +++ b/test/function/samples/emit-file/file-references-in-bundle/_config.js @@ -24,7 +24,7 @@ module.exports = defineTest({ assert.deepStrictEqual(bundle['main.js'].referencedFiles, [ 'assets/asset.txt', 'chunks/ref.js', - 'chunks/My%2FFile.js' + 'chunks/My_2FFile.js' ]); } } @@ -42,7 +42,7 @@ module.exports = defineTest({ assert.deepStrictEqual(exports, { asset: `${directoryURL}/assets/asset.txt`, chunk: `${directoryURL}/chunks/ref.js`, - urlEncoding: `${directoryURL}/chunks/My%252FFile.js` + urlEncoding: `${directoryURL}/chunks/My_2FFile.js` }); } });