Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public static bool IsDigit(this char c)
public static bool IsInvalid(this int c)
{
return c == 0 || c > Symbols.MaximumCodepoint ||
(c > Symbols.UTF16SurrogateMin && c < Symbols.UTF16SurrogateMax);
(c >= Symbols.UTF16SurrogateMin && c <= Symbols.UTF16SurrogateMax);
}

public static bool IsOneOf(this char c, char a, char b)
Expand Down
26 changes: 26 additions & 0 deletions Source/Test/HtmlRenderer.Test/Css/TokenizationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,32 @@ static void Check(string input, TokenType expectedType, string expectedData)
Assert.AreEqual(TokenType.Delim, delim.Get().Type);
}

// CSS Syntax 3 §4.3.7: zero, a surrogate or a code point above U+10FFFF becomes U+FFFD
[TestMethod]
[DataRow(@"'\0'", "�")]
[DataRow(@"'\D800'", "�")]
[DataRow(@"'\DABC'", "�")]
[DataRow(@"'\DFFF'", "�")]
[DataRow(@"'\110000'", "�")]
[DataRow(@"'\D7FF\E000'", "퟿")]
[DataRow(@"'\10FFFF'", "􏿿")]
public void LexerInvalidEscapedCodePointInString(string input, string expected)
{
var token = new Lexer(new TextSource(input)).Get();
Assert.AreEqual(TokenType.String, token.Type);
Assert.AreEqual(expected, token.Data);
}

[TestMethod]
[DataRow(@"a\D800 b")]
[DataRow(@"a\DFFF b")]
public void LexerInvalidEscapedCodePointInIdent(string input)
{
var token = new Lexer(new TextSource(input)).Get();
Assert.AreEqual(TokenType.Ident, token.Type);
Assert.AreEqual("a�b", token.Data);
}

[TestMethod]
public void LexerOnlyCarriageReturn()
{
Expand Down
Loading