Refuse non-media streams and gate video framing
This commit is contained in:
@@ -807,6 +807,13 @@ export function startWebUi(deps: WebUiDeps): WebUiHandle {
|
||||
throw new HttpError(502, `upstream ${upstream.status}`);
|
||||
}
|
||||
|
||||
// Never pipe a page into a media element: embed URLs that are not direct files
|
||||
// (YouTube, provider redirectors) answer with HTML.
|
||||
const upstreamType = upstream.headers.get("content-type") ?? "";
|
||||
if (!/^(image|video|audio|application\/octet-stream)/i.test(upstreamType)) {
|
||||
throw new HttpError(415, `not a media resource (${upstreamType || "unknown"})`);
|
||||
}
|
||||
|
||||
res.status(upstream.status);
|
||||
for (const header of ["content-type", "content-length", "accept-ranges", "content-range"]) {
|
||||
const value = upstream.headers.get(header);
|
||||
|
||||
Reference in New Issue
Block a user