From bd8b53cd6046cef9802d593d8257392d81afb5ce Mon Sep 17 00:00:00 2001 From: Osmium Sorcerer Date: Wed, 3 Jun 2026 11:08:07 +0000 Subject: Eliminate innerHTML manipulation Construct DOM nodes directly instead of trying to sanitize every input string and dynamically updating HTML. Replace all uses of innerHTML with textContent, replaceChildren, and appendChild. This removes the need to use safeTags and replace newlines, but now requires preserving whitespace via CSS pre-wrap. Every OOC chat line is now placed into its own element instead of simply being appended to the log. This might be worse, and createTextNode is another alternative. --- webAO/packets/handlers/handleSM.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'webAO/packets/handlers/handleSM.ts') diff --git a/webAO/packets/handlers/handleSM.ts b/webAO/packets/handlers/handleSM.ts index 1c3fd5e2..21f6ca59 100644 --- a/webAO/packets/handlers/handleSM.ts +++ b/webAO/packets/handlers/handleSM.ts @@ -8,13 +8,13 @@ import { createArea } from "../../client/createArea"; * @param {Array} args packet arguments */ export const handleSM = (args: string[]) => { - document.getElementById("client_loadingtext")!.innerHTML = "Loading Music "; + document.getElementById("client_loadingtext")!.textContent = "Loading Music "; client.resetMusicList(); client.resetAreaList(); client.musics_time = false; - document.getElementById("client_loadingtext")!.innerHTML = `Loading Music`; + document.getElementById("client_loadingtext")!.textContent = `Loading Music`; for (let i = 1; i < args.length - 1; i++) { // Check when found the song for the first time -- cgit