mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
feat(api): ✨ Allow disabled checkbox inputs in rich text
This commit is contained in:
parent
32f71b3adf
commit
dc8a64355a
|
|
@ -79,6 +79,7 @@ export const sanitizeHtml = async (
|
||||||
audio: ["class", "src", "controls"],
|
audio: ["class", "src", "controls"],
|
||||||
source: ["src", "type"],
|
source: ["src", "type"],
|
||||||
track: ["src", "label", "kind"],
|
track: ["src", "label", "kind"],
|
||||||
|
input: ["type", "checked", "disabled", "class"],
|
||||||
},
|
},
|
||||||
stripIgnoreTag: false,
|
stripIgnoreTag: false,
|
||||||
escapeHtml: (unsafeHtml): string =>
|
escapeHtml: (unsafeHtml): string =>
|
||||||
|
|
@ -99,6 +100,7 @@ export const sanitizeHtml = async (
|
||||||
"hashtag",
|
"hashtag",
|
||||||
"ellipsis",
|
"ellipsis",
|
||||||
"invisible",
|
"invisible",
|
||||||
|
"task-list-item-checkbox",
|
||||||
];
|
];
|
||||||
|
|
||||||
return await new HTMLRewriter()
|
return await new HTMLRewriter()
|
||||||
|
|
@ -117,6 +119,17 @@ export const sanitizeHtml = async (
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
// Only allow disabled checkbox input
|
||||||
|
.on("input", {
|
||||||
|
element(element): void {
|
||||||
|
if (
|
||||||
|
element.getAttribute("type") === "checkbox" &&
|
||||||
|
element.getAttribute("disabled") === null
|
||||||
|
) {
|
||||||
|
element.removeAttribute("type");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
.transform(new Response(sanitizedHtml))
|
.transform(new Response(sanitizedHtml))
|
||||||
.text();
|
.text();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue