asticode / go-astisub

Manipulate subtitles in GO (.srt, .ssa/.ass, .stl, .ttml, .vtt (webvtt), teletext, etc.)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ReadFromWebVTT incorrectly returns empty Items if cue timings have two spaces before cue settings

mbetz08 opened this issue · comments

Hi there!

I ran into an issue when parsing a WebVTT file with the ReadFromWebVTT method. Specifically, the parser incorrectly returns an error that the inline style is invalid in the scenario when there are two spaces between the cue timing and cue settings.

For example, parsing this file will return an error because of the two spaces after the end of the cue time and before the word "position":

WEBVTT

00:00:00.580 --> 00:00:03.438  position:50% align:middle
- [Reporter] Hello welcome to today's episode

00:00:03.438 --> 00:00:07.862  position:50% align:middle
Today we're going to talk about cats

The WebVTT spec suggests it's ok to have more than one space:

A WebVTT cue block consists of the following components, in the given order:

Optionally, a WebVTT cue identifier followed by a WebVTT line terminator.
WebVTT cue timings.
Optionally, one or more U+0020 SPACE characters or U+0009 CHARACTER TABULATION (tab) characters followed by a WebVTT cue settings list.

Thanks for help in addressing this.

Thanks for spotting this bug.

I've pushed a fix in master and I've also created a v0.4.0 tag.

Let me know if that fixes your problem.

Cheers

It does- thanks for the quick response and fix!