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

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

Issue 75273002: Handle recovery on "timestamp-looking" lines in the WebVTT parser (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 1 month 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/html/track/vtt/VTTParser.h ('k') | 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/VTTParser.cpp
diff --git a/Source/core/html/track/vtt/VTTParser.cpp b/Source/core/html/track/vtt/VTTParser.cpp
index cddec3461f1916dfc75893afe5b7998e3809b204..0ba5e36700f5feb11c7a93ba54fe087b880394bb 100644
--- a/Source/core/html/track/vtt/VTTParser.cpp
+++ b/Source/core/html/track/vtt/VTTParser.cpp
@@ -179,6 +179,10 @@ void WebVTTParser::parse()
break;
}
+ // Step 15 - Break out of header loop if the line could be a timestamp line.
+ if (line.contains("-->"))
+ m_state = recoverCue(line);
+
// Step 16 - Line is not the empty string and does not contain "-->".
break;
@@ -307,10 +311,19 @@ WebVTTParser::ParseState WebVTTParser::collectTimingsAndSettings(const String& l
WebVTTParser::ParseState WebVTTParser::collectCueText(const String& line)
{
+ // Step 34.
if (line.isEmpty()) {
createNewCue();
return Id;
}
+ // Step 35.
+ if (line.contains("-->")) {
+ // Step 39-40.
+ createNewCue();
+
+ // Step 41 - New iteration of the cue loop.
+ return recoverCue(line);
+ }
if (!m_currentContent.isEmpty())
m_currentContent.append("\n");
m_currentContent.append(line);
@@ -318,11 +331,22 @@ WebVTTParser::ParseState WebVTTParser::collectCueText(const String& line)
return CueText;
}
+WebVTTParser::ParseState WebVTTParser::recoverCue(const String& line)
+{
+ // Step 17 and 21.
+ resetCueValues();
+
+ // Step 22.
+ return collectTimingsAndSettings(line);
+}
+
WebVTTParser::ParseState WebVTTParser::ignoreBadCue(const String& line)
{
- if (!line.isEmpty())
- return BadCue;
- return Id;
+ if (line.isEmpty())
+ return Id;
+ if (line.contains("-->"))
+ return recoverCue(line);
+ return BadCue;
}
// A helper class for the construction of a "cue fragment" from the cue text.
« no previous file with comments | « Source/core/html/track/vtt/VTTParser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698