Stuart Langridge on Nostr: hey, people who know about the HTML Sanitizer API, two questions. 1. am I right in ...
hey, people who know about the HTML Sanitizer API, two questions.
1. am I right in thinking that if I've got a string of HTML I want sanitized, and what I want is a string of sanitized HTML (_not_ to insert it into the page), then I need to do something like temp=document.createElement("div"); temp.setHTML(unsafeHTML); safeHTML=temp.innerHTML ?
2.
https://github.com/AegisJSProject/sanitizer seems an OK polyfill? (gotta polyfill it, it's not in Safari at all, it seems)
Published at
2026-08-20 12:42:13 UTCEvent JSON
{
"id": "a8986cc0927366889f79cc71f67d3523fc12c3f6a475b4380a9fb3112bef8eaa",
"pubkey": "6a68876c20c055f2709522ea42e63cc0a3d925d4c579a510af0d23eccaa7c800",
"created_at": 1787229733,
"kind": 1,
"tags": [
[
"proxy",
"https://mastodon.social/@sil/117127887822389903",
"web"
],
[
"proxy",
"https://mastodon.social/users/sil/statuses/117127887822389903",
"activitypub"
],
[
"L",
"pink.momostr"
],
[
"l",
"pink.momostr.activitypub:https://mastodon.social/users/sil/statuses/117127887822389903",
"pink.momostr"
],
[
"-"
]
],
"content": "hey, people who know about the HTML Sanitizer API, two questions.\n1. am I right in thinking that if I've got a string of HTML I want sanitized, and what I want is a string of sanitized HTML (_not_ to insert it into the page), then I need to do something like temp=document.createElement(\"div\"); temp.setHTML(unsafeHTML); safeHTML=temp.innerHTML ?\n2. https://github.com/AegisJSProject/sanitizer seems an OK polyfill? (gotta polyfill it, it's not in Safari at all, it seems)",
"sig": "5e0d242c5c9773adff56500b13d6e6a440b02521d18b5822777d60560c8bf31f9eeaa58443e71d4bed51919679aba6daaf86fb999723a0d23f4da12ae1eeb755"
}