Handle malformed SAMI without leaking ValueError/AttributeError - #420
Open
eeshsaxena wants to merge 1 commit into
Open
Handle malformed SAMI without leaking ValueError/AttributeError#420eeshsaxena wants to merge 1 commit into
eeshsaxena wants to merge 1 commit into
Conversation
SAMIReader leaked two raw exceptions on malformed input. A <sync> tag with a non-numeric start attribute (e.g. start=abc) blew up in int(float(start)) with ValueError, and a tag with a valueless class or lang attribute (e.g. <p class>) hit value.lower()/value[:2] on None and raised AttributeError/TypeError in _find_lang. Non-numeric start now raises CaptionReadTimingError like the missing start case next to it, and a valueless class/lang attribute is skipped since it carries no language info.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two kinds of malformed SAMI make
SAMIReader().read()leak a raw exception instead of one of theCaptionRead*errors:The first is a non-numeric
startattribute hittingint(float(start)). The second is a valuelessclassattribute (HTMLParser gives it a value ofNone), which_find_langthen calls.lower()on. A barelangattribute trips the sameNonepath viavalue[:2].Non-numeric start now raises
CaptionReadTimingError, matching the missing-start check right next to it. A valueless class/lang attribute carries no language info, so it's just skipped. Added tests for both; the SAMI suite and full suite still pass.