fix: reject control characters in manifest URLs

This commit is contained in:
2026-07-20 18:02:16 +02:00
parent bc0135e528
commit 187871aae4
7 changed files with 152 additions and 8 deletions

View File

@@ -5,6 +5,7 @@ import {
loadToolboxContext,
parseToolboxApp,
parseToolboxCatalog,
resolveWebUrl,
type ToolboxAppManifest,
} from "../src/index.js";
import { describe, expect, it, vi } from "vitest";
@@ -179,6 +180,21 @@ describe("same-origin discovery", () => {
});
describe("loading and links", () => {
it.each([
["TAB", "\t"],
["LF", "\n"],
["CR", "\r"],
["C0", "\u0001"],
["DEL", "\u007f"],
])("rejects %s in URL helper string inputs", (_name, control) => {
expect(() =>
resolveWebUrl(`./before${control}after`, "https://tools.example.test/"),
).toThrow(/control characters/u);
expect(() =>
resolveWebUrl("./tool", `https://tools.example.test/${control}`),
).toThrow(/control characters/u);
});
it("loads a catalog, resolves manifests and URLs, and supports external apps", async () => {
const fetch = vi.fn(
async (input: string | URL | Request, init?: RequestInit) => {