mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
fix(api): 🔒 Correctly put all URIs in profiles through proxy
This commit is contained in:
parent
bd1f09837b
commit
569ba8bf2d
3 changed files with 79 additions and 12 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import { stringifyEntitiesLight } from "stringify-entities";
|
||||
import xss, { type IFilterXSSOptions } from "xss";
|
||||
import { proxyUrl } from "./response.ts";
|
||||
|
||||
export const sanitizedHtmlStrip = (html: string): Promise<string> => {
|
||||
return sanitizeHtml(html, {
|
||||
|
|
@ -129,6 +130,15 @@ export const sanitizeHtml = async (
|
|||
}
|
||||
},
|
||||
})
|
||||
// Rewrite all src tags to go through proxy
|
||||
.on("[src]", {
|
||||
element(element): void {
|
||||
element.setAttribute(
|
||||
"src",
|
||||
proxyUrl(element.getAttribute("src") ?? "") ?? "",
|
||||
);
|
||||
},
|
||||
})
|
||||
.transform(new Response(sanitizedHtml))
|
||||
.text();
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue