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

Unified Diff: Source/core/html/track/vtt/VTTTokenizer.cpp

Issue 150413005: Support escaped char codes in WebVTT tokenizer. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 11 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/track/vtt/VTTTokenizer.cpp
diff --git a/Source/core/html/track/vtt/VTTTokenizer.cpp b/Source/core/html/track/vtt/VTTTokenizer.cpp
index 0d84269f9a0dcba757cd064e0eab6ec0a8f81b9d..5bb06112a987fc794b159ba5aeedac7a6b812c91 100644
--- a/Source/core/html/track/vtt/VTTTokenizer.cpp
+++ b/Source/core/html/track/vtt/VTTTokenizer.cpp
@@ -106,6 +106,7 @@ bool VTTTokenizer::nextToken(VTTToken& token)
StartTagAnnotationState,
EndTagState,
TimestampTagState,
+ EscapeCharacterState,
} state = DataState;
// 4.8.10.13.4 WebVTT cue text tokenizer
@@ -151,6 +152,9 @@ bool VTTTokenizer::nextToken(VTTToken& token)
}
buffer.clear();
WEBVTT_ADVANCE_TO(DataState);
+ } else if (cc == '#') {
+ buffer.clear();
+ WEBVTT_ADVANCE_TO(EscapeCharacterState);
} else if (isASCIIAlphanumeric(cc)) {
buffer.append(static_cast<LChar>(cc));
WEBVTT_ADVANCE_TO(EscapeState);
@@ -174,6 +178,22 @@ bool VTTTokenizer::nextToken(VTTToken& token)
}
END_STATE()
+ WEBVTT_BEGIN_STATE(EscapeCharacterState) {
+ if (cc == ';') {
+ unsigned charCode = buffer.toString().toUIntStrict();
+ result.append(static_cast<UChar>(charCode));
+ buffer.clear();
+ WEBVTT_ADVANCE_TO(DataState);
+ } else if (WTF::isASCIIDigit(cc)) {
+ buffer.append(static_cast<LChar>(cc));
+ WEBVTT_ADVANCE_TO(EscapeCharacterState);
+ } else {
+ buffer.clear();
+ WEBVTT_ADVANCE_TO(DataState);
+ }
+ }
+ END_STATE()
+
WEBVTT_BEGIN_STATE(TagState) {
if (isTokenizerWhitespace(cc)) {
ASSERT(result.isEmpty());
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698