Fix CssInliner tokenizer crash on unquoted data: URLs containing parentheses#105
Draft
Fix CssInliner tokenizer crash on unquoted data: URLs containing parentheses#105
Conversation
…ntheses Agent-Logs-Url: https://github.com/nette/mail/sessions/040c9a82-923c-4f72-ab7f-3733ef611406 Co-authored-by: dg <194960+dg@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix handling of data URLs in CSS inliner
Fix CssInliner tokenizer crash on unquoted data: URLs containing parentheses
Mar 31, 2026
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.
The CSS tokenizer's
T_Urlunquoted-content pattern ([^)]*?) stops at the first)encountered, which breaks SVG data URIs that embed CSS functions liketranslate(),rgba(), or SVGurl(#id)references. The premature stop leaves unparseable tokens (e.g. a lone') that trigger anInvalidArgumentException.Changes
src/Mail/CssInliner.php— Replace the unquoted URL pattern from[^)]*?to one that allows balanced(…)pairs:Handles
(…)groups one level deep — sufficient for all real-world SVG cases (translate(),rgba(), fillurl()references).tests/Mail/CssInliner.phpt— Add three regression tests for unquoted SVG data URIs containing parentheses in content (translate(),rgba(),url(#id)).Example (previously crashing):
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
https://api.github.com/repos/nette/di/zipball/e267934e7e7f55857058e19743f6732183adb4da/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JjBn5P /usr/bin/composer install --no-interaction(http block)/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/Xe7gkm /usr/bin/composer install(http block)/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/wh9MV5 /usr/bin/composer install --no-interaction --prefer-dist --no-plugins(http block)https://api.github.com/repos/nette/neon/zipball/aaea4aa3a8435934f1495ec5ecd5de623221a072/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JjBn5P /usr/bin/composer install --no-interaction(http block)/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/Xe7gkm /usr/bin/composer install(http block)/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/wh9MV5 /usr/bin/composer install --no-interaction --prefer-dist --no-plugins(http block)https://api.github.com/repos/nette/php-generator/zipball/4b54db13b80ac095cf26534d8c4097ab398658da/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JjBn5P /usr/bin/composer install --no-interaction(http block)/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/Xe7gkm /usr/bin/composer install(http block)/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/wh9MV5 /usr/bin/composer install --no-interaction --prefer-dist --no-plugins(http block)https://api.github.com/repos/nette/phpstan-rules/zipball/482780a38690d7ec5eadd181f5ae52f5ef000648/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JjBn5P /usr/bin/composer install --no-interaction(http block)/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/wh9MV5 /usr/bin/composer install --no-interaction --prefer-dist --no-plugins(http block)https://api.github.com/repos/nette/robot-loader/zipball/b662bf257bb22251ff590eefadd63da12ce90cbc/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JjBn5P /usr/bin/composer install --no-interaction(http block)/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/Xe7gkm /usr/bin/composer install(http block)/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/wh9MV5 /usr/bin/composer install --no-interaction --prefer-dist --no-plugins(http block)https://api.github.com/repos/nette/schema/zipball/bc3e09dcf65020fc60346a6d7e530ff93de01abb/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JjBn5P /usr/bin/composer install --no-interaction(http block)/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/Xe7gkm /usr/bin/composer install(http block)/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/wh9MV5 /usr/bin/composer install --no-interaction --prefer-dist --no-plugins(http block)https://api.github.com/repos/nette/tester/zipball/2f986e3ae04cd9287d335992c9d5b765bda52f44/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JjBn5P /usr/bin/composer install --no-interaction(http block)/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/wh9MV5 /usr/bin/composer install --no-interaction --prefer-dist --no-plugins(http block)https://api.github.com/repos/nette/tracy/zipball/a1671f4ff1969b8dc4a51f84e4cca646fa471d8b/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JjBn5P /usr/bin/composer install --no-interaction(http block)/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/wh9MV5 /usr/bin/composer install --no-interaction --prefer-dist --no-plugins(http block)https://api.github.com/repos/nette/utils/zipball/dd5725782de7b9d225d9375c51d211097ace82aa/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JjBn5P /usr/bin/composer install --no-interaction(http block)/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/Xe7gkm /usr/bin/composer install(http block)/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/wh9MV5 /usr/bin/composer install --no-interaction --prefer-dist --no-plugins(http block)https://api.github.com/repos/phpstan/extension-installer/zipball/85e90b3942d06b2326fba0403ec24fe912372936/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JjBn5P /usr/bin/composer install --no-interaction(http block)/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/Xe7gkm /usr/bin/composer install(http block)/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/wh9MV5 /usr/bin/composer install --no-interaction --prefer-dist --no-plugins(http block)https://api.github.com/repos/phpstan/phpstan/zipball/f8cdfd9421b7edb7686a2d150a234870464eac70/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JjBn5P /usr/bin/composer install --no-interaction(http block)/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/Xe7gkm /usr/bin/composer install(http block)/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/wh9MV5 /usr/bin/composer install --no-interaction --prefer-dist --no-plugins(http block)If you need me to access, download, or install something from one of these locations, you can either: