Fully autonomous AI Agents system capable of performing complex penetration testing tasks
Go ai-agentsai-security-toolanthropicautonomous-agentsgolanggptgraphqlmulti-agent-systemoffensive-securityopen-sourceopenaipenetration-testingpenetration-testing-toolsreactsecurity-automationsecurity-testingsecurity-toolsself-hosted
fix(editor): keep literal HTML entities (< & > ") on load
Sergey Kozyrenko2e59e9e12269
diff --git a/frontend/src/components/shared/markdown-editor/editor-markdown.ts b/frontend/src/components/shared/markdown-editor/editor-markdown.tsindex c318e94a..326aa7d3 100644--- a/frontend/src/components/shared/markdown-editor/editor-markdown.ts+++ b/frontend/src/components/shared/markdown-editor/editor-markdown.ts@@ -14,6 +14,24 @@ const createFaithfulMarked = () => {const instance = new Marked();instance.use({+ extensions: [+ // @tiptap/markdown runs decodeHtmlEntities (`<`→`<`, `&`→`&`, `>`→`>`, `"`→`"`) on+ // every text token during parse — a module-scope call its `.lexer()`/`.inlineTokens()` path never+ // routes through marked's walkTokens/hooks, so those can't intercept it. Emit each literal `&` as+ // its own text token pre-encoded to `&`; the decode then nets back to the original byte+ // (`&`→`&`), leaving a source `<`/`&quot;` intact instead of collapsing it to `<`/`"`.+ {+ level: 'inline',+ name: 'literalAmpersand',+ start: (src: string) => {+ const index = src.indexOf('&');++ return index < 0 ? undefined : index;+ },+ tokenizer: (src: string) =>+ src[0] === '&' ? { raw: '&', text: '&', type: 'text' as const } : undefined,+ },+ ],tokenizer: {// These marked tokenizers auto-convert literal text into markup a serialize-side escape can't undo,// mangling Go-template / pentest prose on round-trip. Neutralise the lossy cases, keep what thediff --git a/frontend/src/components/shared/markdown-editor/markdown-editor-extensions.test.ts b/frontend/src/components/shared/markdown-editor/markdown-editor-extensions.test.tsindex 786a7cd2..e52f7f87 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@@ -105,6 +105,22 @@ describe('literal backslashes survive — no doubling (regex classes, Windows pa});});+describe('HTML entities stay literal — decode neutralized (a pentest doc teaching <script> keeps its source)', () => {+ it.each([+ 'encode <script> as text',+ 'ampersand AT&T and a & b',+ 'quote "value" and > alone and < too',+ ])('keeps %s byte-identical', (s) => {+ expect(roundTrip(s)).toBe(s);+ });++ it('literal <tags> (no entity) still stay literal, never entity-encoded', () => {+ expect(roundTrip('use <input> and <container_environment> here')).toBe(+ 'use <input> and <container_environment> here',+ );+ });+});+describe('Underline disabled — ++ never parses, C++/++flags prose survives', () => {it.each(['C++ then C++ again', 'a ++ b ++ c', 'compile ++flags++ here'])('keeps %s byte-identical (no ++ collapse)',@@ -257,7 +273,9 @@ describe('typing matches load — underscore emphasis + bare-URL autolink disablfor (const ch of input) {const { from } = view.state.selection;- const handled = view.someProp('handleTextInput', (handler) => handler(view, from, from, ch));+ const handled = view.someProp('handleTextInput', (handler) =>+ handler(view, from, from, ch, () => view.state.tr),+ );if (!handled) {view.dispatch(view.state.tr.insertText(ch));