Skip to content

fix(capture): distinguish SVG namespaces from attribute values - #5238

Closed
user-github-me wants to merge 1 commit into
heygen-com:mainfrom
user-github-me:fix/capture-svg-namespace-attributes
Closed

user-github-me wants to merge 1 commit into
heygen-com:mainfrom
user-github-me:fix/capture-svg-namespace-attributes

Conversation

@user-github-me

Copy link
Copy Markdown
Contributor

Capturing an inline SVG whose label contains text such as xmlns=demo saves a logo that fails to load as an image: toStandaloneSvg mistakes the label text for a namespace declaration and omits the real SVG namespace. The same regex handling also misreads xlink-looking labels and quoted tag delimiters.

Read namespace declarations and xlink usage from parsed attribute names, then insert the required declarations into the original source. Preserve artwork and label bytes, and leave already-declared SVGs unchanged. This uses the CLI's existing linkedom dependency.

Validation: seven added regressions fail on main, including an actual asset download; all 374 related capture/command tests pass with the fix. Eight Chrome 152 cases run through the real token extractor and asset downloader, then load each saved SVG as an image and verify its dimensions, label, and expected pixel. Existing namespace cases retain byte-identical source. CLI build/typecheck, root lint, formatting, comments, and commit hooks passed.

@jrusso1020

Copy link
Copy Markdown
Collaborator

Thanks for this. The failure needs an SVG attribute value that literally contains xmlns=, which captured sites don't produce in practice, and the quoted > case doesn't occur either because the browser escapes it in outerHTML. Given that, we'd prefer to keep the simpler regex path rather than parse every captured SVG into a DOM. — Rames

@jrusso1020 jrusso1020 closed this Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants