Handle absolute-form static request targets safely
Co-authored-by: Theo Browne <[email protected]>
This commit is contained in:
1 parent
1345ec325a
commit
2d7754c19f
2 files changed
+33
-1
No files matched your search
@@ -695,6 +695,21 @@ describe("resolveStaticAssetPath", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("supports absolute-form request targets by using URL pathname", () => {
|
||||
const result = resolveStaticAssetPath("http://127.0.0.1/assets/main.js?x=1", distRoot);
|
||||
expect(result).toEqual({
|
||||
kind: "file",
|
||||
filePath: path.join(distRoot, "assets", "main.js"),
|
||||
});
|
||||
});
|
||||
|
||||
it("rejects malformed absolute-form request targets", () => {
|
||||
const result = resolveStaticAssetPath("http://%zz", distRoot);
|
||||
expect(result).toEqual({
|
||||
kind: "bad_request",
|
||||
});
|
||||
});
|
||||
|
||||
it("rejects traversal attempts with decoded dot-dot segments", () => {
|
||||
const result = resolveStaticAssetPath("/../package.json", distRoot);
|
||||
expect(result).toEqual({
|
||||
|
||||
Reference in new issue
Block a user