Skip to content

Breakage when minifying at-import with unquoted urls containing semicolons #45

Closed
@zytzagoo

Description

@zytzagoo

Here's a testcase that fails with current master:

@import url(//example.org/foo.css?a&b);
@import url(//example.org/bar.css);

Expected output:

@import url(//example.org/foo.css?a&b);@import url(//example.org/bar.css);

Actual output:

@import url(//example.org/foo.css?a&@import url(//example.org/bar.css);b);

Diff highlight:

Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'@import url(//example.org/foo.css?a&b);@import url(//example.org/bar.css);'
+'@import url(//example.org/foo.css?a&@import url(//example.org/bar.css);b);'

When urls are quoted, the problem doesn't occur (because processStringsCallback() captures and later restores the url "tokens").
However, I cannot control the inputs being given to Minifier.

Do you have any pointers on how to best approach fixing this?
Is this something you think needs fixing at all?

I have a branch ready for a PR over at my fork (with the test suite passing), as this is currently a showstopper for getting the latest version integrated into Autoptimize, however, there's probably a better/smarter way to go about fixing this -- I just needed to get something that works quickly...

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions