Skip to content

Commit

Permalink
fix(text): Allow comments in the TTML parser (#3827)
Browse files Browse the repository at this point in the history
Closes #3766

Backported to v3.0.x

Change-Id: Iff0d66da91c06c49e4b226af522a2cae74b97f2a
  • Loading branch information
Álvaro Velad Galván authored and joeyparrish committed Jan 5, 2022
1 parent 7f0b9d7 commit 2ec8c52
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/text/ttml_text_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,11 @@ shaka.text.TtmlTextParser = class {
!cueElement.hasAttribute('begin') &&
!cueElement.hasAttribute('end');

if (cueElement.nodeType == Node.COMMENT_NODE) {
// The comments do not contain information that interests us here.
return null;
}

if (
cueElement.nodeType != Node.ELEMENT_NODE ||
/* Disregards empty elements without time attributes nor content
Expand Down
9 changes: 9 additions & 0 deletions test/text/ttml_text_parser_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,15 @@ describe('TtmlTextParser', () => {
{periodStart: 0, segmentStart: 0, segmentEnd: 0});
});

it('supports comments in the body', () => {
verifyHelper(
[],
'<tt><body><div>' +
'<!-- text-based TTML -->' +
'</div></body></tt>',
{periodStart: 0, segmentStart: 0, segmentEnd: 0});
});

it('parses alignment from textAlign attribute of a region', () => {
verifyHelper(
[
Expand Down

0 comments on commit 2ec8c52

Please sign in to comment.