Skip to content
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

Unable to parse specific css urls #938

Open
ezzak opened this issue Mar 24, 2025 · 0 comments
Open

Unable to parse specific css urls #938

ezzak opened this issue Mar 24, 2025 · 0 comments

Comments

@ezzak
Copy link

ezzak commented Mar 24, 2025

Minimal repro:

const {transform} = require('lightningcss');
const {Buffer} = require('node:buffer');

transform({
    code: Buffer.from(`.foo {
      background: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'></svg>");
      backgroundColor: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg"></svg>');
    }`),
    minify: true,
  });

This produces an error when parsing the second url, (double quotes inside single quotes). Escaping does not seem to help either.

WASM / playground version does not seem to have the same issue as it is re-applying the quotes (flipping single and double)

https://lightningcss.dev/playground/#%7B%22minify%22%3Atrue%2C%22customMedia%22%3Afalse%2C%22cssModules%22%3Afalse%2C%22analyzeDependencies%22%3Afalse%2C%22targets%22%3A%7B%22chrome%22%3A6225920%7D%2C%22include%22%3A0%2C%22exclude%22%3A0%2C%22source%22%3A%22.foo%20%7B%5Cn%20%20background%3A%20url(%5C%22data%3Aimage%2Fsvg%2Bxml%2C%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%3E%3C%2Fsvg%3E%5C%22)%3B%5Cn%20%20backgroundColor%3A%20url('data%3Aimage%2Fsvg%2Bxml%2C%3Csvg%20xmlns%3D%5C%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%5C%22%3E%3C%2Fsvg%3E')%3B%5Cn%7D%22%2C%22visitorEnabled%22%3Afalse%2C%22visitor%22%3A%22%7B%5Cn%20%20Color(color)%20%7B%5Cn%20%20%20%20if%20(color.type%20%3D%3D%3D%20'rgb')%20%7B%5Cn%20%20%20%20%20%20color.g%20%3D%200%3B%5Cn%20%20%20%20%20%20return%20color%3B%5Cn%20%20%20%20%7D%5Cn%20%20%7D%5Cn%7D%22%2C%22unusedSymbols%22%3A%5B%5D%2C%22version%22%3A%22local%22%7D

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

No branches or pull requests

1 participant