yui / yuicompressor

YUI Compressor
http://yui.github.com/yuicompressor/
Other
3.01k stars 664 forks source link

Inline SVG XML gets compressed into oblivion #141

Open mcombuechen opened 10 years ago

mcombuechen commented 10 years ago

I came across a situation where I wanted to save very small and simple SVG images inline in the CSS, e.g.

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>');
}

YUICompressor will strip all the whitespace from the XML and thus break it:

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

I’d argue that content within url() shouldn’t be minified.

tml commented 10 years ago

I agree. Thanks for filing this.

pVesian commented 9 years ago

Hi, Is there any news for a fix? Thanks

marcelstoer commented 9 years ago

This is a pretty serious defect. We can't currently us the yuicompressor because of this. The fact that it's been open for 1.5 years and 2.4.9 with which it's supposed to be released is only about 30% completed poses a pretty bleak outlook :disappointed:.

tml commented 9 years ago

It's a project that went from having Yahoo! behind it to...a project having ME behind it. Pull requests are welcome!

marcelstoer commented 9 years ago

Oh, I missed that, sorry. I just read their fall 2014 announcement and it sounds like a reasonable move - from Yahoo's perspective. For years the YUI Compressor was the first thing that came to mind when I thought about or heard of JS/CSS minification. Everybody loves PRs, I know (I do for my own projects). I'm not versed enough in JavaScript to help at the moment, sorry. Did you think about reducing the scope of your releases to ship bug fixes earlier?

balapal commented 5 years ago

I have raised a PR for to fix this: https://github.com/yui/yuicompressor/pull/319 Could you please review it and merge it if you are happy with the fix?

NathanSweet commented 5 years ago

@tml There is a fix above!

mgerasimchuk commented 3 years ago

faced with this problem in 2021:(

seb-sykio commented 2 years ago

still same problem in march 2022

syntaxseed commented 2 years ago

Work around is to replace all spaces in your SVG URLs with %20.

NathanSweet commented 2 years ago

yuicompressor is dead. Use esbuild which is not dead and MUCH faster.

MattyBalaam commented 2 years ago

Good necro. My heart goes out to @syntaxseed and everyone else who still needs to find a workaround for this issue, but if you can: please try and invest some time in moving to newer tooling if there's any way you can.