Skip to content

Commit

Permalink
Fix test fail due to incorrect end tag
Browse files Browse the repository at this point in the history
  • Loading branch information
arun1587 committed Sep 14, 2020
1 parent 3e27987 commit 61b4872
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions webvtt.go
Expand Up @@ -25,7 +25,7 @@ const (
// Vars
var (
bytesWebVTTTimeBoundariesSeparator = []byte(webvttTimeBoundariesSeparator)
voiceTagRegexp = regexp.MustCompile(`(<v([\.\w]*)([\s\w]+)+>)*(.[^<]*)(</v>)*`)
voiceTagRegexp = regexp.MustCompile(`(<v([\.\w]*)([\s\w]+)+>)*(.[^<]*)(</v.*>)*`)
)

// parseDurationWebVTT parses a .vtt duration
Expand Down Expand Up @@ -207,7 +207,13 @@ func ReadFromWebVTT(i io.Reader) (o *Subtitles, err error) {

func parseTextWebVTT(i string) (o Line) {
match := voiceTagRegexp.FindStringSubmatch(i)
if len(match) < 5 {
if len(match) < 6 {
return
}

endTag := match[5]
// should be either no tag, or match voice tag
if endTag != "" && endTag != "</v>" {
return
}

Expand Down

0 comments on commit 61b4872

Please sign in to comment.