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
feat(markdown-editor): autolink bare URLs/emails instead of freezing them as text
Sergey Kozyrenkob73350ae2f5c
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.tsindex c9e0bd65..e6b5a6e1 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@@ -134,13 +134,16 @@ describe('Underline disabled — ++ never parses, C++/++flags prose survives', ();});-describe('bare URLs and emails stay literal — explicit [links] still work', () => {- it.each(['see https://example.com/path now', 'contact [email protected] today', 'a <https://example.com> ref'])(- 'keeps %s byte-identical',- (s) => {- expect(roundTrip(s)).toBe(s);- },- );+describe('bare URLs / emails / <autolinks> become links and converge; explicit [links] still work', () => {+ it.each([+ ['see https://example.com/path now', 'see [https://example.com/path](https://example.com/path) now'],+ ['contact [email protected] today', 'contact [[email protected]](mailto:[email protected]) today'],+ ['a <https://example.com> ref', 'a [https://example.com](https://example.com) ref'],+ ])('links %s then stays stable', (src, expected) => {+ const out = roundTrip(src);+ expect(out).toBe(expected);+ expect(roundTrip(out)).toBe(out);+ });it('still round-trips an explicit [link](url)', () => {expect(roundTrip('[docs](https://example.com)')).toContain('[docs](https://example.com)');@@ -282,7 +285,7 @@ describe('findVariableOccurrences — doc spans for the Available-variables cycl});});-describe('typing matches load — underscore emphasis + bare-URL autolink disabled while typing', () => {+describe('typing matches load — underscore emphasis literal, bare URL autolinks like load', () => {const typeString = (input: string): { html: string; md: string } => {const editor = new Editor({ content: '', contentType: 'markdown', extensions: createMarkdownExtensions() });const { view } = editor;@@ -313,8 +316,11 @@ describe('typing matches load — underscore emphasis + bare-URL autolink disablexpect(md).toContain('_word_');});- it('typed bare URL stays literal — no autolink', () => {- expect(typeString('see https://evil.example.com/x done').html).not.toContain('<a ');+ it('typed bare URL autolinks — matches load', () => {+ const { html, md } = typeString('see https://evil.example.com/x done');++ expect(html).toContain('<a ');+ expect(md).toContain('[https://evil.example.com/x](https://evil.example.com/x)');});it('typed *italic* / **bold** / ~~strike~~ still convert (star + double-tilde kept)', () => {diff --git a/frontend/src/components/shared/markdown-editor/markdown-editor-extensions.ts b/frontend/src/components/shared/markdown-editor/markdown-editor-extensions.tsindex a51318bd..ffc292ef 100644--- a/frontend/src/components/shared/markdown-editor/markdown-editor-extensions.ts+++ b/frontend/src/components/shared/markdown-editor/markdown-editor-extensions.ts@@ -73,7 +73,7 @@ const parseFaithfulCodeBlock = (token: MarkdownCodeToken, helpers: MarkdownParse// `_`-emphasis literal on load/paste, so leaving the underscore TYPING rules on would diverge — typed// `__init__`/`_word_` would emphasize (→ `**init**`/`*word*`) while the same text loaded stays literal,// breaking identifiers. Drop only the underscore rules (their `find` regex mentions `_`; the `*` rules stay)-// so typing matches load. codeBlock gets the indented-fence fix above. (Link autolink + Underline off below.)+// so typing matches load. codeBlock gets the indented-fence fix above. (Underline off below.)const StarterKitFaithful = StarterKit.extend({addExtensions() {return (this.parent?.() ?? []).map((extension) => {@@ -105,12 +105,13 @@ const StarterKitFaithful = StarterKit.extend({// tuned for our content (see markdown-editor-marked.ts); VariableHighlight/TagHighlight are view-only decorations// ({{vars}} / <tags>) that don't affect serialization.// • underline: false — its `++text++` markdown corrupts `C++ … C++` prose on load and Ctrl+U emits `++`.-// • link autolink/linkOnPaste: false — a typed/pasted bare URL stays literal (matches load); explicit-// [text](url) and the toolbar link button still work.+// • link autolink/linkOnPaste: true — a bare URL/email becomes a link on load, paste, AND typing, kept+// symmetric with the marked layer (which no longer neutralises autolink/url). Do NOT set false: it+// diverges typing from load and re-freezes bare URLs as text.export const createMarkdownExtensions = (placeholder?: string) => [StarterKitFaithful.configure({codeBlock: { HTMLAttributes: { class: 'hljs' } },- link: { autolink: false, linkOnPaste: false },+ link: { autolink: true, linkOnPaste: true },underline: false,}),MarkdownTable.configure({ resizable: true }),diff --git a/frontend/src/components/shared/markdown-editor/markdown-editor-marked.ts b/frontend/src/components/shared/markdown-editor/markdown-editor-marked.tsindex 52021b99..1a21c9cb 100644--- a/frontend/src/components/shared/markdown-editor/markdown-editor-marked.ts+++ b/frontend/src/components/shared/markdown-editor/markdown-editor-marked.ts@@ -41,14 +41,13 @@ const createFaithfulMarked = () => {// • escape — keep `\`+punct literal (`\.` `\*` `\|` `\\`); marked's default DROPS the backslash// (CommonMark unescape), silently corrupting regex/paths on the first load// • html/tag — keep `<xml-like>` tags literal (marked swallows real-HTML-element names)- // • autolink/url — keep bare `https://…` / `<url>` / emails literal (marked wraps them in [](…))- autolink: () => undefined,+ // NB: autolink/url are intentionally NOT neutralised — a bare `https://…`, `<url>` or email is+ // meant to become a link (see markdown-editor-extensions.ts link config, kept symmetric with typing).del: (src: string) => (/^~~(?!~)/.test(src) ? false : undefined),emStrong: (src: string) => (/^_/.test(src) ? undefined : false),escape: () => undefined,html: () => undefined,tag: () => undefined,- url: () => undefined,},});