videojs / vtt.js

A JavaScript implementation of the WebVTT specification, forked from vtt.js for use with Video.js
http://dev.w3.org/html5/webvtt/
Other
70 stars 43 forks source link

CR delimited VTT files not supported #64

Open mlitwin opened 1 year ago

mlitwin commented 1 year ago

VTT files with carriage return (CR \r) line endings are rejected by the parser with a ParsingError.Errors.BadSignature error.

Issue seems to be the regex at https://github.com/videojs/vtt.js/blob/2eb1ea469f06478cd40268fe9d7de5746dee60fb/lib/parser/parser.js#L175 not handling the \r case, resulting in downstream rejection because it seems like there's only one line in the vtt.

Per https://www.w3.org/TR/webvtt1/#webvtt-line-terminator "A single U+000D CARRIAGE RETURN (CR) character." should be supported.

Other notes:

mister-ben commented 1 year ago

We would need to make sure \r\n can never be interpreted as two line breaks which wuld also break parsing.

mlitwin commented 1 year ago

Yeah - thought the https://github.com/videojs/vtt.js/blob/2eb1ea469f06478cd40268fe9d7de5746dee60fb/lib/parser/parser.js#L45C12-L45C27 collectNextLine() function seems like it already handles that case. There's another regex at https://github.com/videojs/vtt.js/blob/2eb1ea469f06478cd40268fe9d7de5746dee60fb/lib/parser/parser.js#L192 that looks like it needs an \r test.