Skip to content

Commit

Permalink
fix: Fix WebVTT parser failure on REGION blocks (#4915)
Browse files Browse the repository at this point in the history
We do not yet support VTT region settings, but we should still not fail
when a region block appears in a VTT file.

Related to work on PR #4767
  • Loading branch information
joeyparrish committed Jan 30, 2023
1 parent c6b4078 commit c534602
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/text/vtt_text_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@ shaka.text.VttTextParser = class {
return null;
}

// Skip style blocks.
if (text[0] == 'STYLE') {
// Skip style and region blocks.
if (text[0] == 'STYLE' || text[0] == 'REGION') {
return null;
}

Expand Down
16 changes: 16 additions & 0 deletions test/text/vtt_text_parser_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -1064,6 +1064,22 @@ describe('VttTextParser', () => {
{periodStart: 0, segmentStart: 0, segmentEnd: 0, vttOffset: 0});
});

it('does not fail on REGION blocks', () => {
verifyHelper(
[
{
startTime: 10, endTime: 20,
payload: 'test',
},
],
'WEBVTT\n\n' +
'REGION\n' +
'id:1\n\n' +
'00:00:10.000 --> 00:00:20.000\n' +
'test\n\n',
{periodStart: 0, segmentStart: 0, segmentEnd: 0, vttOffset: 0});
});

/**
* @param {!Array} cues
* @param {string} text
Expand Down

0 comments on commit c534602

Please sign in to comment.