Merge pull request #1295 from morluto/fix/javascript-html-url-whitespace-admission
fix(javascript): reject encoded separators joined by HTML URL whitespace
This commit is contained in:
@@ -264,6 +264,12 @@ const htmlCandidate = (
|
|||||||
return unresolvedOutcome(input, "external", [
|
return unresolvedOutcome(input, "external", [
|
||||||
"The document base href is external, so its script reference is not a local artifact path.",
|
"The document base href is external, so its script reference is not a local artifact path.",
|
||||||
]);
|
]);
|
||||||
|
// Removing URL tabs and newlines can join an encoded dot or separator that
|
||||||
|
// the raw declaration split, so admit the parsed URL text again.
|
||||||
|
if (!admitsCanonicalPathSyntax(declared))
|
||||||
|
return unresolvedOutcome(input, "rejected", [
|
||||||
|
"Encoded dot or separator bytes are rejected before artifact path resolution.",
|
||||||
|
]);
|
||||||
const declaredPath = percentDecodeUrlPath(declared);
|
const declaredPath = percentDecodeUrlPath(declared);
|
||||||
if (declaredPath === null)
|
if (declaredPath === null)
|
||||||
return unresolvedOutcome(input, "rejected", [
|
return unresolvedOutcome(input, "rejected", [
|
||||||
|
|||||||
@@ -150,6 +150,12 @@ describe("HTML reference URL text", () => {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
it("rejects a base href whose URL whitespace splits an encoded separator", () => {
|
||||||
|
expect(resolve("app.js", "a%2\nf/")).toMatchObject({
|
||||||
|
resolution_status: "rejected",
|
||||||
|
resolved_path: null,
|
||||||
|
});
|
||||||
|
});
|
||||||
it("rejects a base href that decodes to NUL", () => {
|
it("rejects a base href that decodes to NUL", () => {
|
||||||
expect(resolve("app.js", "/a%00/")).toMatchObject({
|
expect(resolve("app.js", "/a%00/")).toMatchObject({
|
||||||
resolution_status: "rejected",
|
resolution_status: "rejected",
|
||||||
@@ -164,7 +170,7 @@ describe("HTML reference URL text", () => {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
it.each(["%2e%2e/app.js", "a%2fapp.js"])(
|
it.each(["%2e%2e/app.js", "a%2fapp.js", "%2\nfapp.js", "%2\ne%2\te/app.js"])(
|
||||||
"still rejects encoded dot and separator bytes in %j",
|
"still rejects encoded dot and separator bytes in %j",
|
||||||
(declared) => {
|
(declared) => {
|
||||||
expect(resolve(declared, "")).toMatchObject({
|
expect(resolve(declared, "")).toMatchObject({
|
||||||
|
|||||||
Reference in New Issue
Block a user