fix(javascript): resolve HTML script URLs after URL whitespace and percent decoding

An HTML script src or base href with percent-encoded letters or
surrounding whitespace was looked up literally, so an inventoried script
was reported as not-found. Apply HTML attribute and URL parser
whitespace handling, then percent-decode the path as the URL standard
does. Encoded dot and separator bytes are still rejected, and paths that
decode to NUL or non-UTF-8 bytes are rejected explicitly.

Closes #1236

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kaoru0822
2026-10-09 13:52:55 +00:00
co-authored by Claude Opus 5.5
parent 0c6852b392
commit 502528c58d
5 changed files with 156 additions and 10 deletions
@@ -55,6 +55,24 @@ const cases: readonly {
files: { "app.js": "globalThis.owned = true;" },
expected: ["app.js"],
},
{
name: "percent-encoded script letters",
html: '<script src="%61pp.js"></script>',
files: { "app.js": "globalThis.owned = true;" },
expected: ["app.js"],
},
{
name: "script URL surrounded by whitespace",
html: '<script src=" app.js "></script>',
files: { "app.js": "globalThis.owned = true;" },
expected: ["app.js"],
},
{
name: "percent-encoded base directory",
html: '<base href="%61ssets/"><script src="app.js"></script>',
files: { "assets/app.js": "globalThis.owned = true;" },
expected: ["assets/app.js"],
},
];
it.each(cases)(