fix(web): preserve XML-like tags in user messages#4133
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 6fc3bad. Configure here.
ApprovabilityVerdict: Approved Simple, well-tested bug fix that adds a boolean prop to preserve XML-like tags as literal text in user messages. The change is self-contained with comprehensive test coverage including XSS protection verification. You can customize Macroscope's approvability policy. Learn more. |
Render user-authored XML-like source as escaped text while retaining sanitized assistant HTML, with regression coverage for custom tags, code, comparisons, and unsafe input. Co-authored-by: codex <codex@users.noreply.github.com>
6fc3bad to
f0da0f7
Compare

Summary
Root cause
ChatMarkdownalways enabled raw HTML parsing and sanitization. Unknown XML-like elements in user input, such as<global-agent-instructions>, were therefore interpreted as HTML and removed from the rendered message.User messages now opt out of raw HTML parsing, so their original text remains visible. Assistant messages keep the existing sanitized HTML behavior.
User impact
The rendered user message now matches what was typed instead of silently omitting XML-like tags. This only changes presentation; the message payload sent to the agent was already correct.
Fixes #4059.
Validation
pnpm exec vp test apps/web/src/components/chat/MessagesTimeline.test.tsx(14 tests passed)pnpm exec vp check(0 errors; 10 existing warnings)pnpm exec vp run typecheckNote
Preserve XML-like tags as text in user messages
parseRawHtmlprop (defaulttrue) toChatMarkdownthat controls whether HTML-like content is parsed into elements or rendered as inert source text.parseRawHtml={false}for all user message rendering inUserMessageBody, so XML-like tags and comparison operators in user input appear as escaped text rather than HTML.<details>/<summary>.Macroscope summarized f0da0f7.
Note
Low Risk
Presentation-only change for user bubbles with stricter display of user HTML; assistant markdown path is unchanged and tests lock in XSS-safe user rendering.
Overview
Fixes user chat bubbles silently dropping XML-like text (e.g.
<global-agent-instructions>) because ChatMarkdown always ran raw HTML parsing and sanitization.Adds a
parseRawHtmlflag (defaulttrue) that toggles therehype-raw/rehype-sanitizepipeline. Whenfalse, HTML-like input is shown as escaped source text instead of being parsed or stripped. User message rendering in MessagesTimeline opts out withparseRawHtml={false}on every ChatMarkdown path; assistant messages keep the default so supported markup (e.g.<details>) still renders after sanitization.Regression tests cover literal XML/comparisons in user text, inert handling of malicious user HTML, and unchanged sanitized assistant HTML behavior.
Reviewed by Cursor Bugbot for commit f0da0f7. Bugbot is set up for automated code reviews on this repo. Configure here.