From a6d3984ad51e3f3e6d76a1e341972f1d4200240b Mon Sep 17 00:00:00 2001 From: Phil LaFayette Date: Fri, 26 Jun 2026 04:50:20 -0500 Subject: [PATCH] Fix batch of verified web audit findings (XSS, send button, store sync, parsers) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit WEB-E (HIGH): CodeBlock no longer renders the raw pre-Shiki fallback via {@html}. Until the async Shiki highlight resolves, code lines render as escaped text nodes, closing the XSS window where a code block containing from a chat message executed. WEB-B (HIGH): MessageInput send button now considers blockMode.body, so a code-block-only message (inputValue empty, body in block mode) is sendable via the button instead of being permanently disabled. WEB-A (MED): markAllRead passes mark_seen:true so the server read cursor advances (unread/mention dot no longer resurrect on reconnect); sendMessage/forwardMessage strip the internal status field before publish (no more stuck "Sending…" spinner on other clients); forwardMessage no longer inflates the sender's own unread (self-author guard). WEB-C (MED/LOW): mention name char-class aligned to the server authority [\w-] (no dot) in mentions.js and dm-parser.js (utils.js already matched); highlight-word match lowercases the word so uppercase words match; removed dead utils.parseInlineCode and the dead _pendingActivity stash. Tests: +8 (1292 -> 1300). Added CodeBlock pre-highlight escape test, send-enabled/disabled block-mode tests, forward self-unread + wire status-strip tests, uppercase highlight-word test, dot-terminator parser tests; corrected the markAllRead call-shape assertion. --- web/src/components/CodeBlock.svelte | 5 +- web/src/components/MessageInput.svelte | 4 +- web/src/lib/dm-parser.js | 8 ++-- web/src/lib/mentions.js | 14 +++--- web/src/lib/mqtt-store.svelte.js | 51 ++++++++++++++------- web/src/lib/notifications.svelte.js | 2 +- web/src/lib/utils.js | 27 ----------- web/tests/code-block-shiki.spec.js | 43 ++++++++++++++++- web/tests/composer-backtick.spec.js | 49 ++++++++++++++++++++ web/tests/dm-parser.spec.js | 10 ++++ web/tests/mentions.spec.js | 13 ++++++ web/tests/mqtt-store-forward-queue.spec.js | 20 ++++++++ web/tests/mqtt-store-mark-read.spec.js | 4 ++ web/tests/notifications-policy-gate.spec.js | 22 +++++++++ 14 files changed, 213 insertions(+), 59 deletions(-) diff --git a/web/src/components/CodeBlock.svelte b/web/src/components/CodeBlock.svelte index 758d967..e3f6473 100644 --- a/web/src/components/CodeBlock.svelte +++ b/web/src/components/CodeBlock.svelte @@ -64,8 +64,9 @@ {/if} -
{#each (highlightedLines.length ? highlightedLines : codeLines) as html, i (i)}{i + 1}{@html html}
-{/each}
+
{#if highlightedLines.length}{#each highlightedLines as html, i (i)}{i + 1}{@html html}
+{/each}{:else}{#each codeLines as line, i (i)}{i + 1}{line}
+{/each}{/if}