Skip to content

GraphicsStyle: reject a NaN or infinite stroke dash pattern or phase - #2117

Merged
andersonhc merged 2 commits into
py-pdf:masterfrom
RavSinghChandan:dash-pattern-finite
Nov 7, 2026
Merged

andersonhc merged 2 commits into
py-pdf:masterfrom
RavSinghChandan:dash-pattern-finite

Conversation

@RavSinghChandan

Copy link
Copy Markdown

An SVG with stroke-dasharray="nan 2" wrote [nan 2] 0 d into the page, and stroke-dashoffset="inf" an infinite phase; neither is a valid PDF number. The same happened when setting them directly on a GraphicsStyle.

GraphicsStyle.stroke_dash_pattern and stroke_dash_phase now raise a ValueError for NaN or infinity, like FPDF.set_dash_pattern() does since #2103. As the SVG parser goes through these setters, an SVG with such a value now raises like one with stroke-dasharray="bad".

Tests added to the invalid style parameters and the SVG attribute conversion tests (they fail on master).

  • A unit test is covering the code added / modified by this PR
  • A mention of the change is present in CHANGELOG.md
  • This PR is ready to be merged

@andersonhc
andersonhc merged commit 97d3b83 into py-pdf:master Nov 7, 2026
23 checks passed
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