Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit 538420dddcc1ea73a26699ed362d71fd4d8ae736
parent 457d3eaf47e5e1e5eedd15a311dd2a2b13b54e1a
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Thu, 19 Nov 2026 00:01:56 -0500

clip windows: review 4 C -- a caller's webpageUrl is a full http(s) address, or nothing is asked

POST /api/media/fetch-window answers 400, and a fetch-windows item is refused
with the reason, when the page address it gives does not begin http:// or
https:// -- before the cache, the archive or any job.

Co-Authored-By: Claude <noreply@anthropic.com>

Diffstat:
Meditor/app/api/media/fetch-window/route.test.ts | 11+++++++++++
Meditor/app/api/media/fetch-window/route.ts | 9+++++++++
Meditor/app/channels/[slug]/videos/fetchWindowsAction.test.ts | 16++++++++++++++++
Meditor/app/channels/[slug]/videos/fetchWindowsAction.ts | 6++++++
4 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/editor/app/api/media/fetch-window/route.test.ts b/editor/app/api/media/fetch-window/route.test.ts @@ -68,6 +68,17 @@ test("maxHeight out of range, fractional or not a number is refused with 400", a } }); +// Review 4 C: a caller's page address is a full http(s) address, or nothing +// is asked — before the cache, the archive or any job. +test("a webpageUrl that is not an http(s) address is refused with 400", async () => { + for (const webpageUrl of ["x.com/u/status/1", "t.co/AbC", "//x.com/u/status/1", "ftp://example.org/a.mp4", "javascript:alert(1)", "www.youtube.com/watch?v=abc123"]) { + const res = await post({ ...base, webpageUrl }); + assert.equal(res.status, 400, webpageUrl); + const body = (await res.json()) as { error: string }; + assert.match(body.error, /^webpageUrl must be an http\(s\) address/, webpageUrl); + } +}); + test("a cached window answers with its probed height", async () => { await writeFile(path.join(VIDEO_DIR, "clips", "5.00-25.00.mp4"), "not really an mp4"); const res = await post({ ...base, maxHeight: 720 }); diff --git a/editor/app/api/media/fetch-window/route.ts b/editor/app/api/media/fetch-window/route.ts @@ -214,6 +214,15 @@ export async function POST(request: Request) { // its whole recording — `full`, or a window on a whole-recording platform — // is refused with the recording's size (409) unless `allowWholeRecording`. let webpageUrl = str(body.webpageUrl); + // A CALLER'S PAGE ADDRESS IS A FULL http(s) ADDRESS (review 4 C), before the + // cache, the archive or any job: one written without its scheme ("x.com/…") + // is read by no rule the same way twice. + if (webpageUrl !== undefined && !/^https?:\/\//i.test(webpageUrl)) { + return NextResponse.json( + { error: `webpageUrl must be an http(s) address (https://…): ${JSON.stringify(webpageUrl)} is not one. Nothing was asked.` }, + { status: 400 }, + ); + } { const paths = getPaths(); const getJson = cachedArchiveGetJson(); diff --git a/editor/app/channels/[slug]/videos/fetchWindowsAction.test.ts b/editor/app/channels/[slug]/videos/fetchWindowsAction.test.ts @@ -158,6 +158,22 @@ test("a held window a queued saved-video job will already cut is answered in inF } }); +// Review 4 C: an item's page address is a full http(s) address, or that item +// is refused with the reason (and its batch, at the job's door). +test("an item whose webpageUrl is not an http(s) address is refused", async () => { + const bad = ["x.com/u/status/1", "t.co/AbC", "ftp://example.org/a.mp4"]; + const r = await fetchWindowsAction({ items: bad.map((webpageUrl, i) => ({ slug: SLUG, id: "held1", from: 1 + i, to: 2 + i, webpageUrl })), requestedBy: "test", dryRun: true }); + assert.ok(r.ok); + if (!r.ok) return; + assert.equal(r.groups.length, 0); + assert.deepEqual(r.unresolved.map((u) => u.item.webpageUrl), bad); + for (const u of r.unresolved) assert.match(u.error, /^webpageUrl must be an http\(s\) address/); + const { fetchWindowsJobAction } = await import("./fetchWindowsAction"); + const job = await fetchWindowsJobAction({ items: [{ slug: SLUG, id: "held1", from: 1, to: 2, webpageUrl: "x.com/u/status/1" }], requestedBy: "test", queueKey: "platform:twitter" }); + assert.equal(job.ok, false); + assert.match(job.ok ? "" : job.error, /webpageUrl must be an http\(s\) address/); +}); + // Release 29 E2: a recording gone from its platform (lib/sourceGone.ts) has no // page to fetch from — refused at the door — unless the item names a copy's // URL (find-copy), which is the only way such a window is fetched. diff --git a/editor/app/channels/[slug]/videos/fetchWindowsAction.ts b/editor/app/channels/[slug]/videos/fetchWindowsAction.ts @@ -211,6 +211,12 @@ function itemProblem(item: FetchWindowsItem): string | null { `(at most ${MAX_CLIP_WINDOW_SECONDS}s, from < to, from >= 0)` ); } + // A CALLER'S PAGE ADDRESS IS A FULL http(s) ADDRESS (review 4 C): one + // written without its scheme ("x.com/…") is read by no rule the same way twice. + const page = typeof item.webpageUrl === "string" ? item.webpageUrl.trim() : ""; + if (page && !/^https?:\/\//i.test(page)) { + return `webpageUrl must be an http(s) address (https://…): ${JSON.stringify(page)} is not one. Nothing was asked.`; + } return null; }