Harden SVG path parser and add tests for robustness#389
Merged
JimBobSquarePants merged 3 commits intomainfrom May 10, 2026
Merged
Harden SVG path parser and add tests for robustness#389JimBobSquarePants merged 3 commits intomainfrom
JimBobSquarePants merged 3 commits intomainfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #389 +/- ##
===================================
Coverage 85% 86%
===================================
Files 107 107
Lines 8339 8353 +14
Branches 1066 1079 +13
===================================
+ Hits 7168 7190 +22
+ Misses 925 915 -10
- Partials 246 248 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Prerequisites
Description
Fixes #385
This pull request significantly refactors and improves the robustness of the SVG path parsing logic in
Path.cs, addressing edge cases and malformed input handling. The changes introduce stricter validation for SVG arc flags, ensure full operand groups are parsed before appending geometry, and replace several parsing helpers with safer, more explicit methods. Additionally, new unit tests are added to verify correct handling of malformed arc data.SVG Path Parsing Improvements:
TryFindFlag, ensuring only valid "0" or "1" values are accepted and preventing malformed arc flag/end-point boundaries from being parsed incorrectly. [1] [2]TryFindPoint,TryFindScaler, andTryReadScalar, providing better error checking and preventing partially parsed segments from being added to the path. This also ensures that only complete operand groups are processed for each SVG command. [1] [2] [3] [4]Code Quality and Safety Enhancements:
ParseFloat) with a saferTryParseFloatmethod that validates numeric input and ensures only finite floats are accepted.Testing:
Issue_385.csto verify that malformed arc data is correctly rejected byTryParseSvgPath, increasing reliability for edge cases.