diff options
| author | Osmium Sorcerer <os@sof.beauty> | 2026-06-03 11:23:33 +0000 |
|---|---|---|
| committer | Osmium Sorcerer <os@sof.beauty> | 2026-06-06 03:09:27 +0000 |
| commit | fd75f3116aa30eb4958cc747f944f202ec69a484 (patch) | |
| tree | 2afb99a17a2fe3c832c8eae0f0e7594ea806b7e9 /webAO/packets/handlers/handleMS.ts | |
| parent | bd8b53cd6046cef9802d593d8257392d81afb5ce (diff) | |
Remove safeTags, decodeChat, and prepChat
Following the removal of innerHTML manipulation, we no longer need these
sanitization functions.
I've reviewed every safeTags call site to make sure the outputs don't
end up anywhere unsafe, and malicious input can't malipulate DOM or
execute code. These values either end up either as plain text
(textContent, innerText, createTextNode, title, option) or as a URL
path to request assets to the server (encoded using encodeURI).
That is, if safeTags was even effective, considering all that function
did was replace '<' and '>' symbols with Unicode lookalikes. Even the
comment was suggesting the use of fundamentally safer functions instead
of these hacks.
Replace remaining uses of prepChat with unescapeChat as we still need
to do the token substitution (like "<and>" to "&"). decodeChat was
escaping Unicode sequences like \uXXXX, but I don't see the reason for
this, AO2 Client doesn't have this feature, and considering WebSocket
text frames are strictly UTF-8, we don't need these encodings.
Diffstat (limited to 'webAO/packets/handlers/handleMS.ts')
| -rw-r--r-- | webAO/packets/handlers/handleMS.ts | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/webAO/packets/handlers/handleMS.ts b/webAO/packets/handlers/handleMS.ts index 5a9d789..ab2e1d1 100644 --- a/webAO/packets/handlers/handleMS.ts +++ b/webAO/packets/handlers/handleMS.ts @@ -3,7 +3,7 @@ import { client, extrafeatures, UPDATE_INTERVAL } from "../../client"; import { handleCharacterInfo, ensureCharIni } from "../../client/handleCharacterInfo"; import { resetICParams } from "../../client/resetICParams"; -import { prepChat, safeTags } from "../../encoding"; +import { unescapeChat } from "../../encoding"; import { handle_ic_speaking } from "../../viewport/utils/handleICSpeaking"; /** * Handles an in-character chat message. @@ -13,7 +13,7 @@ export const handleMS = (args: string[]) => { // duplicate message if (args[5] !== client.viewport.getChatmsg().content) { const char_id = Number(args[9]); - const char_name = safeTags(args[3]); + const char_name = args[3]; let msg_nameplate = args[3]; let msg_blips = "m"; @@ -58,21 +58,21 @@ export const handleMS = (args: string[]) => { if (char_muted === false) { let chatmsg = { - deskmod: Number(safeTags(args[1])), - preanim: safeTags(args[2]), // get preanim + deskmod: Number(args[1]), + preanim: args[2], nameplate: msg_nameplate, chatbox: char_chatbox, name: char_name, - sprite: safeTags(args[4]), - content: prepChat(args[5]), // Escape HTML tags + sprite: args[4], + content: unescapeChat(args[5]), side: args[6], - sound: safeTags(args[7]), - blips: safeTags(msg_blips), + sound: args[7], + blips: msg_blips, type: Number(args[8]), charid: char_id, snddelay: Number(args[10]), objection: Number(args[11]), - evidence: Number(safeTags(args[12])), + evidence: Number(args[12]), flip: Number(args[13]), flash: Number(args[14]), color: Number(args[15]), @@ -81,10 +81,10 @@ export const handleMS = (args: string[]) => { if (args.length > 16) { const extra_cccc = { - showname: prepChat(args[16]), + showname: unescapeChat(args[16]), other_charid: Number(args[17]), - other_name: safeTags(args[18]), - other_emote: safeTags(args[19]), + other_name: args[18], + other_emote: args[19], self_offset: args[20].split("&"), other_offset: args[21].split("&"), other_flip: Number(args[22]), @@ -96,9 +96,9 @@ export const handleMS = (args: string[]) => { const extra_27 = { looping_sfx: Number(args[24]), screenshake: Number(args[25]), - frame_screenshake: safeTags(args[26]), - frame_realization: safeTags(args[27]), - frame_sfx: safeTags(args[28]), + frame_screenshake: args[26], + frame_realization: args[27], + frame_sfx: args[28], }; chatmsg = Object.assign(extra_27, chatmsg); |
