mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 881475 - Drop cues with malformed timestamps. r=rillian
The parsing specification requires the UA to drop cues containing malformed cue-times. (http://dev.w3.org/html5/webvtt/#dfn-collect-a-webvtt-timestamp) The OnReportError callback has been modified to notify the parser that we need need to drop such cues which are deemed 'malformed' according to the timestamp parsing rules.
This commit is contained in:
parent
371dcbd4ae
commit
f5b7023a3b
@ -207,7 +207,7 @@ WebVTTLoadListener::OnParsedCue(webvtt_cue* aCue)
|
||||
mElement->mTrack->AddCue(*textTrackCue);
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
WebVTTLoadListener::OnReportError(uint32_t aLine, uint32_t aCol,
|
||||
webvtt_error aError)
|
||||
{
|
||||
@ -225,6 +225,19 @@ WebVTTLoadListener::OnReportError(uint32_t aLine, uint32_t aCol,
|
||||
|
||||
LOG("error: %s(%d:%d) - %s\n", file.get(), aLine, aCol, error);
|
||||
#endif
|
||||
|
||||
switch(aError) {
|
||||
// Errors which should result in dropped cues
|
||||
// if the return value is negative:
|
||||
case WEBVTT_MALFORMED_TIMESTAMP:
|
||||
return -1;
|
||||
|
||||
// By default, we can safely ignore other errors
|
||||
// or else parsing the document will be aborted regardless
|
||||
// of the return value.
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void WEBVTT_CALLBACK
|
||||
@ -240,8 +253,7 @@ WebVTTLoadListener::OnReportErrorWebVTTCallBack(void* aUserData, uint32_t aLine,
|
||||
webvtt_error aError)
|
||||
{
|
||||
WebVTTLoadListener* self = static_cast<WebVTTLoadListener*>(aUserData);
|
||||
self->OnReportError(aLine, aCol, aError);
|
||||
return WEBVTT_SUCCESS;
|
||||
return self->OnReportError(aLine, aCol, aError);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
|
@ -61,7 +61,7 @@ public:
|
||||
WebVTTLoadListener(HTMLTrackElement* aElement);
|
||||
~WebVTTLoadListener();
|
||||
void OnParsedCue(webvtt_cue* aCue);
|
||||
void OnReportError(uint32_t aLine, uint32_t aCol, webvtt_error aError);
|
||||
int OnReportError(uint32_t aLine, uint32_t aCol, webvtt_error aError);
|
||||
// Loads the libwebvtt parser. Must call this function in order to the
|
||||
// WebVTTLoadListener to be ready to accept data.
|
||||
nsresult LoadResource();
|
||||
|
Loading…
Reference in New Issue
Block a user