{"action":"created","issue":{"url":"https://api.github.com/repos/google/ExoPlayer/issues/3228","repository_url":"https://api.github.com/repos/google/ExoPlayer","labels_url":"https://api.github.com/repos/google/ExoPlayer/issues/3228/labels{/name}","comments_url":"https://api.github.com/repos/google/ExoPlayer/issues/3228/comments","events_url":"https://api.github.com/repos/google/ExoPlayer/issues/3228/events","html_url":"https://github.com/google/ExoPlayer/issues/3228","id":254404053,"number":3228,"title":"WebVTTCueParser Matcher and NullPointerException","user":{"login":"q-litzler","id":3338489,"avatar_url":"https://avatars2.githubusercontent.com/u/3338489?v=4","gravatar_id":"","url":"https://api.github.com/users/q-litzler","html_url":"https://github.com/q-litzler","followers_url":"https://api.github.com/users/q-litzler/followers","following_url":"https://api.github.com/users/q-litzler/following{/other_user}","gists_url":"https://api.github.com/users/q-litzler/gists{/gist_id}","starred_url":"https://api.github.com/users/q-litzler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/q-litzler/subscriptions","organizations_url":"https://api.github.com/users/q-litzler/orgs","repos_url":"https://api.github.com/users/q-litzler/repos","events_url":"https://api.github.com/users/q-litzler/events{/privacy}","received_events_url":"https://api.github.com/users/q-litzler/received_events","type":"User","site_admin":false},"labels":[{"id":106814989,"url":"https://api.github.com/repos/google/ExoPlayer/labels/bug","name":"bug","color":"fc2929","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-08-31T17:03:26Z","updated_at":"2017-09-04T23:03:51Z","closed_at":null,"author_association":"NONE","body":"### Issue description\r\nIt is possible to encounter a NPE [here](https://github.com/google/ExoPlayer/blob/release-v2/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/WebvttCueParser.java#L102), when `secondLine` is null.\r\n\r\n`secondLine` can be null when the subtitle file is not well formatted.\r\n\r\nHere is a [link](http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6178785) to the RegexMatcher behavior regarding null arguments.\r\n\r\nProposed solution: Handle the NPE gracefully, somehow.\r\n\r\n### Reproduction steps\r\nThis is happening in production of our app, and sadly I can't pinpoint the corrupted .vtt file on our end. (I would have to check hours of content in 10 different languages ..). If I find it, I will update this issue with a link to test content.\r\n\r\n### Link to test content\r\nSee above\r\n\r\n### Version of ExoPlayer being used\r\n2.5.1\r\n\r\n### Device(s) and version(s) of Android being used\r\nAll versions from 5.0 to 7.1.2. Wide range of devices. (This is happening in production)\r\n\r\n### A full bug report captured from the device\r\n```\r\nFatal Exception: java.lang.NullPointerException: Attempt to invoke interface method 'int java.lang.CharSequence.length()' on a null object reference\r\n       at java.util.regex.Matcher.reset(Matcher.java:995)\r\n       at java.util.regex.Matcher.<init>(Matcher.java:174)\r\n       at java.util.regex.Pattern.matcher(Pattern.java:1006)\r\n       at com.google.android.exoplayer2.text.webvtt.WebvttCueParser.parseCue(WebvttCueParser.java:102)\r\n       at com.google.android.exoplayer2.text.webvtt.WebvttDecoder.decode(WebvttDecoder.java:83)\r\n       at com.google.android.exoplayer2.text.webvtt.WebvttDecoder.decode(WebvttDecoder.java:30)\r\n       at com.google.android.exoplayer2.text.SimpleSubtitleDecoder.decode(SimpleSubtitleDecoder.java:70)\r\n       at com.google.android.exoplayer2.text.SimpleSubtitleDecoder.decode(SimpleSubtitleDecoder.java:25)\r\n       at com.google.android.exoplayer2.decoder.SimpleDecoder.decode(SimpleDecoder.java:222)\r\n       at com.google.android.exoplayer2.decoder.SimpleDecoder.run(SimpleDecoder.java:188)\r\n       at com.google.android.exoplayer2.decoder.SimpleDecoder.access$000(SimpleDecoder.java:25)\r\n       at com.google.android.exoplayer2.decoder.SimpleDecoder$1.run(SimpleDecoder.java:66)\r\n```"},"comment":{"url":"https://api.github.com/repos/google/ExoPlayer/issues/comments/327037119","html_url":"https://github.com/google/ExoPlayer/issues/3228#issuecomment-327037119","issue_url":"https://api.github.com/repos/google/ExoPlayer/issues/3228","id":327037119,"user":{"login":"dbrain","id":237995,"avatar_url":"https://avatars1.githubusercontent.com/u/237995?v=4","gravatar_id":"","url":"https://api.github.com/users/dbrain","html_url":"https://github.com/dbrain","followers_url":"https://api.github.com/users/dbrain/followers","following_url":"https://api.github.com/users/dbrain/following{/other_user}","gists_url":"https://api.github.com/users/dbrain/gists{/gist_id}","starred_url":"https://api.github.com/users/dbrain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dbrain/subscriptions","organizations_url":"https://api.github.com/users/dbrain/orgs","repos_url":"https://api.github.com/users/dbrain/repos","events_url":"https://api.github.com/users/dbrain/events{/privacy}","received_events_url":"https://api.github.com/users/dbrain/received_events","type":"User","site_admin":false},"created_at":"2017-09-04T23:03:51Z","updated_at":"2017-09-04T23:03:51Z","author_association":"CONTRIBUTOR","body":"This looks similar to https://github.com/google/ExoPlayer/pull/3185 which was an NPE when parsing the timing line of a subrip subtitle. Presumably also due to a corrupted subtitle file, but I could not reproduce myself (just saw Crashlytics issues).\r\n\r\nMight be worth reviewing how all of the sub parsers handle corrupt subs / EOF in unexpected places."}}
{"actor":{"display_login":"dbrain"}}