trullock / NUglify

NUglify is a HTML, JavaScript and CSS minification Library for .NET (fork of AjaxMin + new features)
Other
396 stars 79 forks source link

Possible bug minifying CSS when using HEX content value #308

Closed norcino closed 2 years ago

norcino commented 2 years ago

I tested with the latest version of the code here in master.

Describe the bug The minification produces the wrong result when an input is provided with HEX character value

To Reproduce

var css = ".something: before { content: \"\\E900\"; }";

Console.WriteLine($"Minifying: {css}");

var minifiedCss = NUglify.Uglify.Css(css);

Console.WriteLine($"Minified css: {minifiedCss}");

Minified output or stack trace .something: before{content:"?"}

Excepted output code .something: before{content:"\E900"}

norcino commented 2 years ago

Not a bug, it looks like this is the behaviour by design, to address this issue I used the following:

var cssSettings = new CssSettings();
cssSettings.DecodeEscapes = false;
var minifiedCss = NUglify.Uglify.Css(css, cssSettings);
trullock commented 2 years ago

Your workaround should arguably be the default, not going to break everyone's world by flipping this though