Repository navigation
SVGs with a loose "&" or HTML entities convert again - #125
Merged
Merged
Conversation
Generated SVGs often have "Q&A" in a <text> or " "/"©", which
stopped Svg.Skia's XML parser ("An error occurred while parsing
EntityName"). When an SVG can't be read, Filee escapes ampersands that
don't start a reference and turns HTML entities into character
references, then reads it again. Declared DTD entities, the DOCTYPE,
comments and CDATA are left alone; valid SVGs are never changed.
Closes #120.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #120.
Generated SVGs (the report's came from Gemini) often have a loose
&in a<text>("Q&A") or HTML entities like and©. XML doesn't allow either, and Svg.Skia's parser stopped with "An error occurred while parsing EntityName".When an SVG can't be read,
SvgRenderer.Loadnow repairs it withSvgXmlRepair.FixAmpersandsand reads it again:&that doesn't start a character reference or a known entity becomes& → )&ns_svg;), the DOCTYPE, comments and CDATA are left aloneValid SVGs are never changed: the repair only runs after a failed read, and it returns nothing when there was nothing to fix.
Tests: an SVG with
Q&A, ,©and an unknown entity converts to PNG. Unit tests cover the repairs and the cases left untouched.🤖 Generated with Claude Code