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): stop escaping a lone ~ so Go-template prose round-trips byte-exact
Sergey Kozyrenko443fcc90eee1
diff --git a/frontend/src/components/shared/editor-markdown.ts b/frontend/src/components/shared/editor-markdown.tsindex 028772b7..25f2c822 100644--- a/frontend/src/components/shared/editor-markdown.ts+++ b/frontend/src/components/shared/editor-markdown.ts@@ -24,8 +24,12 @@ const createFaithfulMarked = () => {// ``` ` * _ [ ] ~ ``` — both corrupt our content (tags become entities, `[1-1000]`/`*.php`/`snake_case`// gain stray backslashes). Text serialization is hard-coded in the manager (no per-extension hook), so we// retune that one method: drop the entity-encoding entirely, and backslash-escape only the chars that-// would otherwise re-parse as inline syntax (`` ` ``, `~`, `\`).-const faithfulEscape = (text: string): string => text.replace(/([\\`~])/g, '\\$1');+// would otherwise re-parse as inline syntax: `` ` `` and `\` always, and `~` only when doubled — a lone+// `~` is literal in GFM, so escaping it would inject a stray `\` into prose like `~10%`.+const faithfulEscape = (text: string): string =>+ text.replace(/[\\`]|~+/g, (match) =>+ match[0] === '~' ? (match.length > 1 ? match.replace(/~/g, '\\~') : match) : `\\${match}`,+ );type ManagerWithEncode = {codeTypes: Set<string>;diff --git a/frontend/src/components/shared/markdown-editor-extensions.test.ts b/frontend/src/components/shared/markdown-editor-extensions.test.tsindex 515e7102..9983097e 100644--- a/frontend/src/components/shared/markdown-editor-extensions.test.ts+++ b/frontend/src/components/shared/markdown-editor-extensions.test.ts@@ -63,6 +63,19 @@ describe('selective escape — no stray backslashes on literal punctuation', ());});+describe('lone tilde stays literal — no stray backslash injected (M1)', () => {+ it.each(['~10% for environment setup', 'approximately ~5 minutes', 'a ~ b ~ c'])(+ 'keeps %s byte-identical',+ (s) => {+ expect(roundTrip(s)).toBe(s);+ },+ );++ it('still round-trips ~~strikethrough~~ (double tilde unaffected)', () => {+ expect(roundTrip('use ~~deprecated~~ here')).toContain('~~deprecated~~');+ });+});+describe('inline marks round-trip', () => {it.each(['**bold**', '*italic*', '`code span`', '~~strike~~', '[a link](https://example.com)', '**bold `code` end**'])('preserves %s',