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

Unified Diff: Source/core/css/CSSMarkup.cpp

Issue 1253403005: Implement CSS.escape (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix final test Created 5 years, 5 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 | « Source/core/css/CSSMarkup.h ('k') | Source/core/css/DOMWindowCSS.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/CSSMarkup.cpp
diff --git a/Source/core/css/CSSMarkup.cpp b/Source/core/css/CSSMarkup.cpp
index 69764aa7de4ee7133cfc73a53fab16c7e1403bb3..c715f5d8b25a5e1db7f73ac7338b73fb3c32de44 100644
--- a/Source/core/css/CSSMarkup.cpp
+++ b/Source/core/css/CSSMarkup.cpp
@@ -200,7 +200,7 @@ static void serializeCharacterAsCodePoint(UChar32 c, StringBuilder& appendTo)
appendTo.append(' ');
}
-void serializeIdentifier(const String& identifier, StringBuilder& appendTo)
+bool serializeIdentifier(const String& identifier, StringBuilder& appendTo)
{
bool isFirst = true;
bool isSecond = false;
@@ -208,12 +208,17 @@ void serializeIdentifier(const String& identifier, StringBuilder& appendTo)
unsigned index = 0;
while (index < identifier.length()) {
UChar32 c = identifier.characterStartingAt(index);
+ if (c == 0) {
+ // Check for lone surrogate which characterStartingAt does not return.
+ c = identifier[index];
+ if (c == 0)
+ return false;
+ }
+
index += U16_LENGTH(c);
- if (c <= 0x1f || (0x30 <= c && c <= 0x39 && (isFirst || (isSecond && isFirstCharHyphen))))
+ if (c <= 0x1f || c == 0x7f || (0x30 <= c && c <= 0x39 && (isFirst || (isSecond && isFirstCharHyphen))))
serializeCharacterAsCodePoint(c, appendTo);
- else if (c == 0x2d && isSecond && isFirstCharHyphen)
- serializeCharacter(c, appendTo);
else if (0x80 <= c || c == 0x2d || c == 0x5f || (0x30 <= c && c <= 0x39) || (0x41 <= c && c <= 0x5a) || (0x61 <= c && c <= 0x7a))
appendTo.append(c);
else
@@ -227,6 +232,7 @@ void serializeIdentifier(const String& identifier, StringBuilder& appendTo)
isSecond = false;
}
}
+ return true;
}
void serializeString(const String& string, StringBuilder& appendTo)
« no previous file with comments | « Source/core/css/CSSMarkup.h ('k') | Source/core/css/DOMWindowCSS.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698