-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 case where TTML data is an empty string #1960
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please run ./build/all.py
to check for style issues and add a unit test in test/text/ttml_text_parser_unit.js
.
Thanks.
lib/text/ttml_text_parser.js
Outdated
@@ -47,6 +47,10 @@ shaka.text.TtmlTextParser = class { | |||
const parser = new DOMParser(); | |||
let xml = null; | |||
|
|||
// dont try to parse empty string as | |||
// DOMParser will not throw error but return an errored xml | |||
if (str == '') return ret |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs curly brackets and needs to be on the next line.
ok will do |
@TheModMaker hello, i finally took the time to write the unit test and fix the code style Thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Let me run it by the build bot.
Test Failure:
|
It looks like there is an explicit test to reject the empty string. You'll need to edit that. The other failure should be fixed with a rebase. |
ok thanks, i should have seen that another test was checking empty string and expected a rebase would be needed :) |
when using DOMParser parseFromString with an empty string it returns an errored XML document the next part of the code is then executed and throw an unnecessary error
@TheModMaker i rebased and removed part of unit test that was conflicting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. I'll have the build bot check it once more.
All tests passed! |
When using DOMParser parseFromString with an empty string, it returns an errored XML document. The next part of the code is then executed and throws an unnecessary error. This adds a special case for an empty string. Change-Id: Icb25d0d50f59b77f3bac0785e785163521276fe1
when using DOMParser parseFromString with an empty string it returns an errored XML document
the next part of the code is then executed and throw an unnecessary error