Skip to content

User messages render raw HTML (<details>, <b>, <img>) instead of showing the typed text (regression from #4343) #4546

Closed

Description

@benwaffle

Summary

Typing HTML in a thread message, for example <details><summary>x</summary>hidden</details>, makes the sent message bubble render the HTML: a collapsed disclosure widget, bold text, a broken image. Before #4343, bb showed the same input as literal text. The sanitizer still strips event handlers, so this is not script execution. But a user who pastes a snippet that contains HTML, or asks the agent about a tag, sees their message changed. Content can also disappear: the hidden text sits inside a collapsed <details>.

Versions and environment

  • bb 0.44.0 desktop app (fork build over upstream main at b23150d88ecc42bcd0e8f96386be0db23f0b1fe4). The code path is unchanged on main at 36aacc040ec0a2b092785d65dee7869d02cec08e.
  • macOS 26.6 (25G72), Apple Silicon.
  • Rendered in the desktop app's web UI (http://127.0.0.1:38886). I took the screenshot and read the DOM with Playwright's chrome-headless-shell 1223 over CDP.
  • Provider does not matter: this is the user's own bubble. I used Claude Code with Haiku 4.5.

Steps to reproduce

  1. Save this prompt to a file:

    cat > /tmp/html-prompt.md <<'EOF'
    HTML render test. Reply with exactly the word ok and nothing else, do not run any tools.
    
    <details><summary>x</summary>hidden</details>
    
    inline <b>bold</b> here
    
    <img src=x onerror=alert(1)>
    EOF
  2. bb thread spawn --project <project-id> --prompt-file /tmp/html-prompt.md

  3. Open the thread in the app and look at the user message bubble.

Typing the same text into the prompt box gives the same result.

Expected vs actual

Expected: the bubble shows the text I typed, tags included, as it did before #4343:

<details><summary>x</summary>hidden</details>
inline <b>bold</b> here
<img src=x onerror=alert(1)>

Actual: the bubble contains real elements. From the live DOM:

<p>HTML render test. Reply with exactly the word ok and nothing else, do not run any tools.</p>
<details><summary>x</summary>hidden</details>
<p>inline <b>bold</b> here</p>
<img alt="Image" loading="lazy" data-markdown-image="" data-markdown-image-offset="162" src="x">

On screen this is a "▶ x" disclosure (with "hidden" collapsed), the word bold in bold, and a broken-image icon. onerror is stripped: the <img> has no onerror attribute, a stubbed window.alert recorded no calls, and CDP reported no Page.javascriptDialogOpening event.

Screenshot: removed.

Evidence

User message bubbles render their text through CollapsibleMessageText, and #4343 added allowHtml to it:

) : (
<MarkdownPreview
allowHtml
content={
collapsedPreview?.wasCapped === true
? closeUnterminatedMarkdownCodeSpan(body.text)
: body.text
}
promptMentions={promptMentions}
threadMentions={rawThreadMentions}
linkRouting={linkRouting}

(called from the user bubble at
<CollapsibleMessageText
mentions={mentions}
resolveMentionLink={resolveMentionLink}
resolveSegmentLinkHref={resolveSegmentLinkHref}
linkRouting={linkRouting}
text={text}
mutePrefixLength={mutePrefixLength || undefined}
/>
)

When the content contains <, allowHtml switches MarkdownPreview to the HTML pipeline:

const rendersHtml = allowHtml && content.includes("<");

That pipeline is rehype-raw followed by rehype-sanitize with GitHub's defaultSchema plus video. It allows details, summary, b, img, and so on, and drops on* attributes:

const MARKDOWN_HTML_REHYPE_PLUGINS: MarkdownRehypePlugins = [
rehypeRaw,
[
rehypeSanitize,
{
...defaultSchema,
tagNames: [
...(defaultSchema.tagNames ?? []),
"video",
"bb-thread-mention",
"bb-prompt-mention",
"bb-message-directive",
],
protocols: { ...defaultSchema.protocols, poster: ["http", "https"] },
attributes: {
...defaultSchema.attributes,
source: [
...(defaultSchema.attributes?.source ?? []),
"src",
"type",
"media",
],
video: [
"src",
"controls",
"playsInline",
"preload",
"poster",
"width",
"height",
"title",
"ariaLabel",
],
"bb-thread-mention": [
"dataThreadId",
"dataRawThreadId",
"dataRawThreadInlineCode",
],
"bb-prompt-mention": ["dataMentionIndex"],
"bb-message-directive": ["dataDirectiveIndex"],
},
},
],

History:

Suggested fix: remove allowHtml from CollapsibleMessageText. User text then renders as it did before #4343. Agent output keeps sanitized HTML and <video>.

What you ruled out

Suggested priority and effort

Low to medium priority, small effort (one prop). It affects anyone who pastes HTML, XML-like, or JSX snippets as prose instead of in a code fence. The workaround is to wrap the text in backticks or a code fence. The tags themselves disappear from the displayed message (for example <Foo> in prose), and text inside <details> is collapsed out of view. The stored prompt is not changed.

AGENT GENERATED

Activity

  1. added theissue type on Sep 30, 2026
  2. added
    ui
    on Sep 30, 2026
  3. added a commit that references this issue on Sep 30, 2026
    27cf8ee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ui

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions