Skip to content

Commit 9315302

Browse files
BunsDevzhangfan49Nova
committed
fix(ui): replace marked.js with markdown-it to fix ReDoS UI freeze (openclaw#46707) thanks @zhangfnf
Replace marked.js with markdown-it for the control UI chat markdown renderer to eliminate a ReDoS vulnerability that could freeze the browser tab. - Configure markdown-it with custom renderers matching marked.js output - Add GFM www-autolink with trailing punctuation stripping per spec - Escape raw HTML via html_block/html_inline overrides - Flatten remote images to alt text, preserve base64 data URI images - Add task list support via markdown-it-task-lists plugin - Trim trailing CJK characters from auto-linked URLs (RFC 3986) - Keep marked dependency for agents-panels-status-files.ts usage Co-authored-by: zhangfan49 <zhangfan49@baidu.com> Co-authored-by: Nova <nova@openknot.ai>
1 parent f94d677 commit 9315302

7 files changed

Lines changed: 869 additions & 132 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Docs: https://docs.openclaw.ai
44

55
## Unreleased
66

7+
- fix(ui): replace marked.js with markdown-it to fix ReDoS UI freeze (#46707) thanks @zhangfnf
8+
79
### Changes
810

911
- Telegram/forum topics: surface human topic names in agent context, prompt metadata, and plugin hook metadata by learning names from Telegram forum service messages. (#65973) Thanks @ptahdunbar.

pnpm-lock.yaml

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ui/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@
1313
"@noble/ed25519": "3.0.1",
1414
"dompurify": "^3.3.3",
1515
"lit": "^3.3.2",
16+
"markdown-it": "^14.1.1",
17+
"markdown-it-task-lists": "^2.1.1",
1618
"marked": "^18.0.0"
1719
},
1820
"devDependencies": {
21+
"@types/markdown-it": "^14.1.2",
1922
"@vitest/browser-playwright": "4.1.4",
2023
"jsdom": "^29.0.2",
2124
"playwright": "^1.59.1",

ui/src/markdown-it-task-lists.d.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
declare module "markdown-it-task-lists" {
2+
import type MarkdownIt from "markdown-it";
3+
interface TaskListsOptions {
4+
enabled?: boolean;
5+
label?: boolean;
6+
labelAfter?: boolean;
7+
}
8+
const plugin: (md: MarkdownIt, options?: TaskListsOptions) => void;
9+
export default plugin;
10+
}

ui/src/styles/chat/text.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,20 @@
4141
margin-top: 0.25em;
4242
}
4343

44+
/* Hide default marker only for unordered task lists; ordered lists keep numbers */
45+
.chat-text :where(ul > .task-list-item),
46+
.sidebar-markdown :where(ul > .task-list-item),
47+
.chat-thinking :where(ul > .task-list-item) {
48+
list-style: none;
49+
}
50+
51+
.chat-text :where(.task-list-item-checkbox),
52+
.sidebar-markdown :where(.task-list-item-checkbox),
53+
.chat-thinking :where(.task-list-item-checkbox) {
54+
margin-right: 0.4em;
55+
vertical-align: middle;
56+
}
57+
4458
.chat-text :where(a) {
4559
color: var(--accent);
4660
text-decoration: underline;

0 commit comments

Comments
 (0)