Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
hxrshxz wants to merge 2 commits into processing:main
base: main
Choose a base branch
Loading
from hxrshxz:svg

Conversation

@hxrshxz
Copy link

@hxrshxz hxrshxz commented Oct 14, 2025

Fixes #1244

Summary

Adds support for compact SVG arc notation where flags and coordinates are concatenated (e.g., a2 2 0 013 3 instead of a 2 2 0 0 1 3 3). Previously crashed with ArrayIndexOutOfBoundsException.

Changes

  • core/src/processing/core/PShapeSVG.java: Added isCompactArcNotation() helper method to detect and parse concatenated arc flags/coordinates for both A and a commands
  • core/test/processing/core/PShapeSVGPathTest.java: Added 4 test cases covering compact notation, standard notation, and edge cases

Before

Screencast.from.2025年10月15日.00-31-18.mp4

After

Screencast.from.2025年10月14日.23-14-15.mp4

@Copilot Copilot AI review requested due to automatic review settings October 14, 2025 19:41
Copy link

Copilot AI left a 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.

Copy link
Author

hxrshxz commented Oct 14, 2025

@catilac have a look :)

Copy link
Collaborator

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.

Copy link
Author

hxrshxz commented Oct 15, 2025

Thanks @Stefterv I have added tests to verify the actual parsed endpoint values, not just that the shape doesn't crash

Stefterv reacted with hooray emoji

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot Copilot left review comments

@Stefterv Stefterv Awaiting requested review from Stefterv

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Loading SVG fails for some files

2 participants

AltStyle によって変換されたページ (->オリジナル) /