fix(sanitizer): match attribute quotes by type to avoid mangling content by bymle · Pull Request #1371 · anthropics/claude-code-action (original) (raw)
stripHiddenAttributes used the pattern ["'][^"']*["'] for each quoted
attribute, which matches an opening quote of either type and stops at the
first quote of either type. When a value contained the other quote
character — e.g. an apostrophe inside a double-quoted attribute like
title="We'll do it" — the match terminated at the apostrophe, so the
wrong span was removed and the surrounding text was corrupted (e.g.
<Tooltip title="We'll do it" placement="top"> became
<Tooltipll do it" placement="top">).
This surfaced via the github_inline_comment MCP tool: suggestion blocks whose code lines contain quotes were mangled before posting (anthropics#1366).
Match each quoted form per quote type ("[^"]*" and '[^']*'),
mirroring stripMarkdownLinkTitles, so a value may freely contain the
other quote character. The unquoted fallback is unchanged.
Closes anthropics#1366