diff --git a/frontend/src/components/shared/markdown-editor/markdown-editor-content-integrity.test.ts b/frontend/src/components/shared/markdown-editor/markdown-editor-content-integrity.test.ts index 1da12c70..532c1584 100644 --- a/frontend/src/components/shared/markdown-editor/markdown-editor-content-integrity.test.ts +++ b/frontend/src/components/shared/markdown-editor/markdown-editor-content-integrity.test.ts @@ -13,8 +13,9 @@ const mulberry32 = (seed: number) => () => { }; // Content atoms that MUST survive load→serialize verbatim: identifiers/dunders, Go-template variables, -// xml-like tags, regex/path backslashes, HTML entities, C++. Whitespace/formatting may reflow; these -// bytes may not disappear or mutate. +// xml-like tags, regex/path backslashes, numeric HTML entities + a bare `&`, C++. Whitespace/formatting may +// reflow; these bytes may not disappear or mutate. (Named entities like `<` decode to `<` by design — +// see markdown-editor-marked.ts — so they are NOT survive-verbatim atoms.) const ATOMS = [ '__init__', '__call__', @@ -32,9 +33,9 @@ const ATOMS = [ 'regex \\.php files', 'glob \\* and \\?', 'escaped \\[ \\| \\+ here', - '<script>', + '(paren)', 'AT&T', - 'x & y', + '2>&1 redirect', 'C++ then C++', '~10% left', ]; diff --git a/frontend/src/components/shared/markdown-editor/markdown-editor-extensions.test.ts b/frontend/src/components/shared/markdown-editor/markdown-editor-extensions.test.ts index e6b5a6e1..3717c7aa 100644 --- a/frontend/src/components/shared/markdown-editor/markdown-editor-extensions.test.ts +++ b/frontend/src/components/shared/markdown-editor/markdown-editor-extensions.test.ts @@ -109,16 +109,27 @@ describe('backslash before punctuation survives — escape tokenizer neutralized }); }); -describe('HTML entities stay literal — decode neutralized (a pentest doc teaching <script> keeps its source)', () => { +describe('named HTML entities decode outside code; numeric refs, bare & and raw survive', () => { it.each([ - 'encode <script> as text', - 'ampersand AT&T and a & b', - 'quote "value" and > alone and < too', + ['encode <script> as text', 'encode