Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix of TTML bug for white-space div with no content #650

Merged
merged 2 commits into from
Jan 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
AdsWizz <*@adswizz.com>
Esteban Dosztal <edosztal@gmail.com>
Google Inc. <*@google.com>
Edgeware AB <*@edgeware.tv>
Itay Kinnrot <Itay.Kinnrot@Kaltura.com>
Jason Palmer <jason@jason-palmer.com>
Jesper Haug Karsrud <jesper.karsrud@gmail.com>
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Sanborn Hilland <sanbornh@rogers.com>
Seth Madison <seth@philo.com>
Thomas Stephens <thomas@ustudio.com>
Timothy Drews <tdrews@google.com>
Torbjörn Einarsson <torbjorn.einarsson@edgeware.tv>
Toshihiro Suzuki <t.suzuki326@gmail.com>
Vasanth Polipelli <vasanthap@google.com>
Vignesh Venkatasubramanian <vigneshv@google.com>
6 changes: 3 additions & 3 deletions lib/media/ttml_text_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,11 @@ shaka.media.TtmlTextParser.parseCue_ = function(

// Disregard empty elements:
// TTML allows for empty elements like <div></div>.
// If cueElement has neither time attributes, nor text,
// don't try to make a cue out of it.
// If cueElement has neither time attributes, nor
// non-whitespace text, don't try to make a cue out of it.
if (!cueElement.hasAttribute('begin') &&
!cueElement.hasAttribute('end') &&
cueElement.textContent == '')
/^\s*$/.test(cueElement.textContent))
return null;

shaka.media.TtmlTextParser.addNewLines_(cueElement);
Expand Down
4 changes: 4 additions & 0 deletions test/media/ttml_text_parser_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ describe('TtmlTextParser', function() {
verifyHelper([], '<tt></tt>');
});

it('supports div with no cues but whitespace', function() {
verifyHelper([], '<tt><body><div> \r\n </div></body></tt>');
});

it('rejects invalid ttml', function() {
errorHelper(shaka.util.Error.Code.INVALID_TTML, '<test></test>');
errorHelper(shaka.util.Error.Code.INVALID_TTML, '');
Expand Down