Skip to content

Commit

Permalink
Fixes #379
Browse files Browse the repository at this point in the history
  • Loading branch information
trullock committed Feb 4, 2024
1 parent 76ec539 commit 9b3e7cb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
17 changes: 14 additions & 3 deletions src/NUglify.Tests/Css/Bugs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,26 @@ public void Bug317()
}").Code);
}

[Test]
public void Bug343()
[Test]
public void Bug343()
{
Assert.AreEqual("body{border:0 none;border:0 none #f00}", Uglify.Css(@"
body
{
border: 0 none;
border: 0 none #f00;
}").Code);
}").Code);
}


[Test]
public void Bug379()
{
Assert.AreEqual(".\\!inline-flex{display:inline-flex!important}", Uglify.Css(@"
.\!inline-flex {
display: inline-flex!important
}
").Code);
}
}
}
3 changes: 2 additions & 1 deletion src/NUglify/Css/CssParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4414,9 +4414,10 @@ bool Append(object obj, TokenType tokenType)
for (var ndx = firstIndex + 1; ndx < text.Length; ++ndx)
{
char nextChar = text[ndx];
char? prevChar = text[ndx - 1];

// anything at or above 0x80, then it's okay and doesnt need to be escaped
if (nextChar < 0x80)
if (nextChar < 0x80 && prevChar != '\\')
{
// only -, _, 0-9, a-z, A-Z are allowed without escapes
// but we also want to NOT escape \ or space characters. If the identifier had
Expand Down

0 comments on commit 9b3e7cb

Please sign in to comment.