Skip to content
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
4 changes: 4 additions & 0 deletions webvtt.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ func ReadFromWebVTT(i io.Reader) (o *Subtitles, err error) {

// Split line on space to get remaining of time data
var right = strings.Fields(left[1])
if len(right) == 0 {
err = fmt.Errorf("astisub: line %d: missing webvtt end time boundary", lineNum)
return
}

// Parse time boundaries
if item.StartAt, err = parseDurationWebVTT(left[0]); err != nil {
Expand Down
12 changes: 12 additions & 0 deletions webvtt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,18 @@ func TestWebVTTParseDuration(t *testing.T) {
assert.Equal(t, s.Items[1].InlineStyle.WebVTTAlign, "middle")
}

func TestWebVTTMissingEndTimeBoundary(t *testing.T) {
testData := `WEBVTT

1
00:00:01.000 -->
Some subtitle text`

_, err := astisub.ReadFromWebVTT(strings.NewReader(testData))
require.Error(t, err)
require.Contains(t, err.Error(), "missing webvtt end time boundary")
}

func TestWebVTTColorToTTML(t *testing.T) {
testData := `WEBVTT

Expand Down
Loading