Skip to content

Stylesheet parsing updates#3491

Merged
bsweeney merged 3 commits intomasterfrom
stylesheet-parsing-updates
Dec 2, 2024
Merged

Stylesheet parsing updates#3491
bsweeney merged 3 commits intomasterfrom
stylesheet-parsing-updates

Conversation

@bsweeney
Copy link
Copy Markdown
Member

@bsweeney bsweeney commented Jul 6, 2024

  • Continue rendering when stylesheet parsing fails
  • Modify internal Stylesheet handling of data URIs
  • Improve semi-colon detection during property parsing

bsweeney added 2 commits June 23, 2024 11:49
When parsing a stylesheet containing a large string the regex utilized by Dompdf can fail. Depending on the location of the problematic string, the regex failure can prevent parsing a style property, a style declaration, or an entire stylesheet.

This change is intended to resolve the most likely cause of this type of failure, which is the presence of data URIs in the stylesheet. To work around the regex parsing issues Dompdf replaces data URIs with blob-like URIs. The blob URI shortens the string to a regex-parsable length. When the CSS property value is retrieved the blob URI is rewritten to it's original form.

fixes #3482
@bsweeney bsweeney added this to the 3.0.1 milestone Jul 6, 2024
Regular expressions are problematic for parsing certain string combinations that can be found in CSS property values. In order to improve the accuracy of parsing we will walk the declaration string, splitting on the semi-colon as before, except where the semi-colon falls within defined delimeters.

This change also unescapes semi-colon's where escaped in the resulting property.

fixes #3482
@bsweeney bsweeney force-pushed the stylesheet-parsing-updates branch from 1ba1afb to 126042c Compare July 6, 2024 16:33
@bsweeney bsweeney merged commit 59a8033 into master Dec 2, 2024
@bsweeney bsweeney deleted the stylesheet-parsing-updates branch December 2, 2024 14:54
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.

background-image: url("data:image/png,base64, ...") doesn't work anymore in Dompdf 3.0.0

1 participant