Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(558)

Unified Diff: Source/core/css/parser/CSSTokenizer.cpp

Issue 656033010: CSS Tokenizer: Fix handling of escaped newlines (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/core/css/parser/CSSTokenizerTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/parser/CSSTokenizer.cpp
diff --git a/Source/core/css/parser/CSSTokenizer.cpp b/Source/core/css/parser/CSSTokenizer.cpp
index 443577c3764bbfd9491f596d797cb215d9182ac8..0ef6cb71dccd5a0de1ed595e5561e67f58c91701 100644
--- a/Source/core/css/parser/CSSTokenizer.cpp
+++ b/Source/core/css/parser/CSSTokenizer.cpp
@@ -31,10 +31,16 @@ static bool isNameChar(UChar c)
return isNameStart(c) || isASCIIDigit(c) || c == '-';
}
+static bool isNewLine(UChar cc)
+{
+ // We check \r and \f here, since we have no preprocessing stage
+ return (cc == '\r' || cc == '\n' || cc == '\f');
+}
+
// http://dev.w3.org/csswg/css-syntax/#check-if-two-code-points-are-a-valid-escape
static bool twoCharsAreValidEscape(UChar first, UChar second)
{
- return ((first == '\\') && (second != '\n') && (second != kEndOfFileMarker));
+ return first == '\\' && !isNewLine(second) && second != kEndOfFileMarker;
}
CSSTokenizer::CSSTokenizer(CSSTokenizerInputStream& inputStream)
@@ -353,12 +359,6 @@ CSSParserToken CSSTokenizer::consumeIdentLikeToken()
return CSSParserToken(IdentToken, name);
}
-static bool isNewLine(UChar cc)
-{
- // We check \r and \f here, since we have no preprocessing stage
- return (cc == '\r' || cc == '\n' || cc == '\f');
-}
-
// http://dev.w3.org/csswg/css-syntax/#consume-a-string-token
CSSParserToken CSSTokenizer::consumeStringTokenUntil(UChar endingCodePoint)
{
@@ -379,7 +379,7 @@ CSSParserToken CSSTokenizer::consumeStringTokenUntil(UChar endingCodePoint)
if (m_input.nextInputChar() == kEndOfFileMarker)
continue;
if (isNewLine(m_input.nextInputChar()))
- consume();
+ consumeSingleWhitespaceIfNext(); // This handles \r\n for us
else
output.append(consumeEscape());
} else {
@@ -456,7 +456,7 @@ String CSSTokenizer::consumeName()
UChar CSSTokenizer::consumeEscape()
{
UChar cc = consume();
- ASSERT(cc != '\n');
+ ASSERT(!isNewLine(cc));
if (isASCIIHexDigit(cc)) {
unsigned consumedHexDigits = 1;
StringBuilder hexChars;
« no previous file with comments | « no previous file | Source/core/css/parser/CSSTokenizerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698