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 _-delimited text literal so dunders survive the round-trip
Sergey Kozyrenko81c7eaf3d298
diff --git a/frontend/src/components/shared/editor-markdown.ts b/frontend/src/components/shared/editor-markdown.tsindex 09fd71b5..c6fc0946 100644--- a/frontend/src/components/shared/editor-markdown.ts+++ b/frontend/src/components/shared/editor-markdown.ts@@ -15,10 +15,13 @@ const createFaithfulMarked = () => {instance.use({tokenizer: {- // GFM strikethrough is `~~text~~`; marked also treats a single `~text~` as <del>, which mangles- // prose such as `from ~5~ to ~10~` into strikethrough. Defer real `~~` to the default tokenizer- // and neutralise a lone `~…~` so it stays literal text.+ // marked's del + emphasis tokenizers fire on `~` and `_`, mangling literal prose: `~5~` becomes+ // <del>, and `__init__`/`_word_` become <strong>/<em> (the delimiters are consumed and gone by+ // serialize time, so no serialize-side escape can recover them). Keep real GFM `~~strike~~` and+ // `*`/`**` emphasis (what the toolbar emits); neutralise a lone `~…~` and ALL `_`-delimited+ // emphasis so that text — Python dunders, ranges, snake_case — round-trips verbatim.del: (src: string) => (/^~~(?!~)/.test(src) ? false : undefined),+ emStrong: (src: string) => (/^_/.test(src) ? undefined : false),html: () => undefined,tag: () => undefined,},diff --git a/frontend/src/components/shared/markdown-editor-extensions.test.ts b/frontend/src/components/shared/markdown-editor-extensions.test.tsindex 204c6da0..eba54c68 100644--- a/frontend/src/components/shared/markdown-editor-extensions.test.ts+++ b/frontend/src/components/shared/markdown-editor-extensions.test.ts@@ -80,6 +80,21 @@ describe('single tildes stay literal — no over-escape, no accidental strikethr});});+describe('underscore delimiters stay literal — dunders/identifiers survive, * emphasis still works', () => {+ it.each(['Override __init__ then __call__', 'a _emphasis_ word', 'snake_case_name plus __dunder__'])(+ 'keeps %s byte-identical',+ (s) => {+ expect(roundTrip(s)).toBe(s);+ },+ );++ it('still renders *star* / **star** emphasis (the toolbar delimiter)', () => {+ const out = roundTrip('use *italic* and **bold** here');+ expect(out).toContain('*italic*');+ expect(out).toContain('**bold**');+ });+});+describe('inline marks round-trip', () => {it.each(['**bold**', '*italic*', '`code span`', '~~strike~~', '[a link](https://example.com)', '**bold `code` end**'])('preserves %s',