-
-
Notifications
You must be signed in to change notification settings - Fork 102
Fix ArrayIndexOutOfBoundsException with compact SVG arc notation #1282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes an ArrayIndexOutOfBoundsException that occurred when parsing SVG arc commands with compact notation where flags and coordinates are concatenated (e.g., a2 2 0 013 3). The fix adds support for detecting and properly parsing this compact format.
Key changes:
- Added
isCompactArcNotation()helper method to detect concatenated arc flags and coordinates - Modified arc parsing logic for both absolute (
A) and relative (a) commands to handle compact notation - Added comprehensive test coverage for various compact arc notation scenarios
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| core/src/processing/core/PShapeSVG.java | Implements compact arc notation detection and parsing logic |
| core/test/processing/core/PShapeSVGPathTest.java | Adds test cases for compact notation, standard notation, and edge cases |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
@catilac have a look :)
Hi @hxrshxz great work! Thank you!
Looking at the tests, the one thing I would say to be missing is a step that actually checks if the parsing occurred correctly by looking at the numbers that the parser spits out, I would say just checking if the shape parses is not enough.
Thanks @Stefterv I have added tests to verify the actual parsed endpoint values, not just that the shape doesn't crash
Fixes #1244
Summary
Adds support for compact SVG arc notation where flags and coordinates are concatenated (e.g.,
a2 2 0 013 3instead ofa 2 2 0 0 1 3 3). Previously crashed withArrayIndexOutOfBoundsException.Changes
core/src/processing/core/PShapeSVG.java: AddedisCompactArcNotation()helper method to detect and parse concatenated arc flags/coordinates for bothAandacommandscore/test/processing/core/PShapeSVGPathTest.java: Added 4 test cases covering compact notation, standard notation, and edge casesBefore
Screencast.from.2025年10月15日.00-31-18.mp4
After
Screencast.from.2025年10月14日.23-14-15.mp4