Skip to content

Fully autonomous AI Agents system capable of performing complex penetration testing tasks

test(markdown-editor): pin multi-cycle entity-decode semantics

Sergey Kozyrenkoc2d04a1d94e0
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 bc8afaef..13dd0d33 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,6 +134,26 @@ describe('named HTML entities decode outside code; numeric refs, bare & and raw
'use <input> and <container_environment> here',
);
});
+
+ // INTENTIONAL (product decision): a multi-encoded entity in prose loses ONE encoding level per open+save
+ // cycle until fully decoded — outside code, `&lt;` means `<`. Do NOT "fix" by re-encoding `&` on save:
+ // that would freeze the single-level ingestion artifacts the decode exists to clean.
+ it('multi-encoded prose entity decodes one level per cycle, then stabilizes', () => {
+ const p1 = roundTrip('literal &amp;lt; here');
+ const p2 = roundTrip(p1);
+ const p3 = roundTrip(p2);
+
+ expect(p1).toBe('literal &lt; here');
+ expect(p2).toBe('literal < here');
+ expect(p3).toBe(p2);
+ });
+
+ it('multi-encoded entity inside inline code is byte-stable across cycles', () => {
+ const p1 = roundTrip('code `&amp;lt;` here');
+
+ expect(p1).toBe('code `&amp;lt;` here');
+ expect(roundTrip(p1)).toBe(p1);
+ });
});
describe('Underline disabled — ++ never parses, C++/++flags prose survives', () => {
diff --git a/frontend/src/components/shared/markdown-editor/markdown-editor-marked.ts b/frontend/src/components/shared/markdown-editor/markdown-editor-marked.ts
index 4eb8b9e7..7bfbd058 100644
--- a/frontend/src/components/shared/markdown-editor/markdown-editor-marked.ts
+++ b/frontend/src/components/shared/markdown-editor/markdown-editor-marked.ts
@@ -25,10 +25,11 @@ const createTunedMarked = () => {
// • html/tag — keep `<xml-like>` tags literal (marked swallows real-HTML-element names)
// 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).
- // NB: named HTML entities (`&lt; &gt; &amp; &quot;`) are LEFT to marked's decoder — a bare-prose
- // `&lt;` decodes to `<` (fixes HTML-encoding artifacts from ingestion). Numeric refs (`&#123;`) and
- // anything inside code are untouched; a bare `&` survives as `&`. Don't re-add a literalAmpersand
- // token to "preserve" `&lt;` — that re-freezes the artifacts.
+ // NB: named HTML entities (`&lt; &gt; &amp; &quot;`) are decoded downstream — @tiptap/markdown's
+ // token parsing runs @tiptap/core's decodeHtmlEntities, so a bare-prose `&lt;` becomes `<` (fixes
+ // HTML-encoding artifacts from ingestion). Numeric refs (`&#123;`) and anything inside code are
+ // untouched; a bare `&` survives as `&`. Don't re-add a literalAmpersand token to "preserve"
+ // `&lt;` — that re-freezes the artifacts.
del: (src: string) => (/^~~(?!~)/.test(src) ? false : undefined),
emStrong: (src: string) => (/^_/.test(src) ? undefined : false),
escape: () => undefined,