YUI Compressor is removing spaces from filter values

后端 未结 5 2135
独厮守ぢ
独厮守ぢ 2021-02-07 11:18

I have a css containing filter for adding Grayout images in FF like this:-

filter: url(\"data:image/svg+xml;utf8,         


        
5条回答
  •  执笔经年
    2021-02-07 11:36

    I came across this issue in the PHP port of the compressor (https://github.com/tubalmartin/YUI-CSS-compressor-PHP-port), and tracked it down to a line in the extract_data_urls method.

    This extracts data urls (as you would expect, given its name) from the body of the css to prevent them being minified. However, it does a little bit of processing before it stores them:

    $token = preg_replace('/\s+/', '', $token);
    

    This replaces any run of whitespace characters with nothing, and so strips all the spaces out of the SVG tag. Changing this line to:

    $token = preg_replace('/\s+/', ' ', $token);
    

    fixed the issue for me by leaving a single space present.

    As the PHP version is a direct port of the Java compressor, I would assume that this same bug.

提交回复
热议问题