ndparker/rcssmin

Spaces in urls are removed

Closed this issue · 6 comments

see django-compressor/django-compressor#736.

basically, url("../imgs/Credit cards.png") becomes url("../imgs/Creditcards.png"), which is wrong :)

Uhm. Spaces are not allowed in URLs in the first place. Shouldn't that read %20 instead?

hm. actually i don't know. the reason why this is there is probably that it's a path from the local file system, where spaces are allowed obviously. but you might be right that the reporter should've put a %20 in there when using it as url.

Actually there are specific tests for rcssmin that url spaces are removed. I'm currently researching why they are there. I seem to recall that CSS is even specified that way. Still looking ... ;)

There are various references to URL definitions scattered throughout the specifications. One points to http://www.ietf.org/rfc/rfc3986 - Appendix C is relevant.

Another one points to https://url.spec.whatwg.org/#urls - Besides the fact that the spec looks completely weird... the parser run down in https://url.spec.whatwg.org/#url-parsing explicitely forbids whitespaces.

Assuming that any whitespace inside an URI is there for neater reading, it's completely reasonable to just remove them as a minifier. I'll just close the issue for now. Feel free to reopen if/when other considerations come up.

Thanks!

I think there are some cases where we can consider preserve whitespaces, as using inline SVG XML.

div {
  background-image: url('data:image/svg+xml;utf8,<svg version="1.0" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="200px" height="200px" viewBox="0 0 200 200" xml:space="preserve"><polygon points="200,120 0,120 0,80 200,80 "/></svg>');
}

In that case, it joins everything and the value isn't parsed.

What are you thoughts on this case, @ndparker?

wow!
Said that, https://tools.ietf.org/html/rfc2397 says to use %20 (it also says, the ;utf8 there is invalid and should be specified as charset=utf-8 as part of the mediatype).