fix(api): 🔒 Correctly put all URIs in profiles through proxy

This commit is contained in:
Jesse Wierzbinski 2024-11-22 15:06:46 +01:00
parent bd1f09837b
commit 569ba8bf2d
No known key found for this signature in database
3 changed files with 79 additions and 12 deletions

View file

@ -1,6 +1,5 @@
import { idValidator } from "@/api";
import { localObjectUri } from "@/constants";
import { proxyUrl } from "@/response";
import { sanitizedHtmlStrip } from "@/sanitization";
import { sentry } from "@/sentry";
import { getLogger } from "@logtape/logtape";
@ -902,17 +901,7 @@ export class Note extends BaseInterface<typeof Notes, NoteTypeWithRelations> {
(mention) => mention.instanceId === null,
);
// Rewrite all src tags to go through proxy
let replacedContent = new HTMLRewriter()
.on("[src]", {
element(element): void {
element.setAttribute(
"src",
proxyUrl(element.getAttribute("src") ?? "") ?? "",
);
},
})
.transform(data.content);
let replacedContent = data.content;
for (const mention of mentionedLocalUsers) {
replacedContent = replacedContent.replace(