fix: enforce content policies using original file types

This commit is contained in:
tdurieux committed 2026-09-06 09:17:42 +02:00
1 parent 7210db2b61
commit c14a548cb9
5 files changed
+35 -5

No files matched your search

+2 -1
View File
@@ -105,6 +105,7 @@ router.get(
repository: repo,
anonymizedPath,
});
const originalPath = await f.originalPath();
if (!f.isFileSupported()) {
throw new AnonymousError("file_not_supported", {
httpStatus: 403,
@@ -115,7 +116,7 @@ router.get(
res.attachment(
anonymizedPath.substring(anonymizedPath.lastIndexOf("/") + 1)
);
} else if (isScriptableDocument(anonymizedPath)) {
} else if (isScriptableDocument(originalPath) || isScriptableDocument(anonymizedPath)) {
// A repository's own .html/.svg is untrusted content served from our
// origin: opening it renders it as a document, and any script in it
// would run as the site itself (session cookie, same-origin fetches