Skip to content

Fix CssSyntaxError on unquoted data: URLs in url() - #352

Open
joscha wants to merge 1 commit into
mainfrom
fix/unquoted-data-url-351
Open

joscha wants to merge 1 commit into
mainfrom
fix/unquoted-data-url-351

Conversation

@joscha

@joscha joscha commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

Fixes #351.

postcss.parse() accepts an unquoted url(data:image/png;base64,...) as a single url token, but postcss-values-parser 6.x re-tokenizes the inside of url(...) and throws CssSyntaxError: Unknown word ; (not wrapped as MalformedCssError). It affected @import and @value by default, and declarations with { url: true }.

Fix: a parseValue() helper quotes unquoted url() contents before they reach postcss-values-parser. Existing quoted strings are skipped. Results are unchanged for consumers; data URLs are still ignored.

Tests: src/__tests__/issue.351.spec.ts covers each case from the issue, both with a data URL alone and next to a real reference.

Upgrading postcss-values-parser is not an option for now: 7.x/8.x are a css-tree rewrite with a different node API and higher Node requirements.

postcss-values-parser re-tokenizes the inside of an unquoted url() and throws on characters like ';' (e.g. url(data:image/png;base64,...)), although postcss accepts them as a single url token. Quote unquoted url() contents before handing values to the parser.

Fixes #351
@joscha

joscha commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator Author

@XhmikosR I couldn't find the issue where we discussed this before - it was some package upgrade pull request I think. I am not a massive fan of this, but the automatically reported issue is real.

@XhmikosR

Copy link
Copy Markdown
Member

@joscha: is this an issue due to the is-url-superb change? If so, why don't we switch back to the old dep assuming it doesn't have the bug?

@joscha

joscha commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

I think they are unrelated - is-url-superb only has an issue with protocol-relative URLs (sindresorhus/is-url-superb#6) contrary to the previous package used. The unquoted parsing error happens inside the postcss parsing.

This branch has not been deployed

No deployments
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.

Unquoted data: URLs in url() throw CssSyntaxError

2 participants