minify icon indicating copy to clipboard operation
minify copied to clipboard

Replacing 'white' and 'black' to '#fff' and '#000' breaks fonts

Open peixotorms opened this issue 5 years ago • 1 comments

Hi,

I don't see the point of https://github.com/matthiasmullie/minify/pull/258 but most probably after that, fonts are being rewritten as well.

For example:

@font-face { font-family: "Circular Std Black"; src: url(my_black_font.woff); }
@font-face { font-family: 'Circular Std White'; src: url(my_white_font.woff); }
@font-face { font-family: Circular Std Black; src: url(my_black_font.woff); }
@font-face { font-family: Circular Std White; src: url(my_white_font.woff); }
@font-face { font-family: Black; src: url(my_black_font.woff); }
@font-face { font-family: White; src: url(my_white_font.woff); }

Becomes:

@font-face{font-family:"Circular Std Black";src:url(my_black_font.woff)}
@font-face{font-family:'Circular Std White';src:url(my_white_font.woff)}
@font-face{font-family:Circular Std #000;src:url(my_black_font.woff)}
@font-face{font-family:Circular Std #fff;src:url(my_white_font.woff)}
@font-face{font-family:#000;src:url(my_black_font.woff)}
@font-face{font-family:#fff;src:url(my_white_font.woff)}

So for fonts without quotes, this is a problem. I am aware fonts should have quotes, but when minifying wordpress plugins you don't always have control over what the other developers do.

peixotorms avatar Mar 11 '20 08:03 peixotorms

I'll try to change the regex of shortenColorCodesToHex and send a PR for this. It's possible that this issue occurs in other css properties as well, so I guess it's better to restrict the changes to the color and background properties.

enricodias avatar Apr 20 '20 04:04 enricodias