videojs / vtt.js

A JavaScript implementation of the WebVTT specification, forked from vtt.js for use with Video.js

Home Page:http://dev.w3.org/html5/webvtt/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CR delimited VTT files not supported

mlitwin opened this issue · comments

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

if (!/\r\n|\n/.test(self.buffer)) {
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:

  • See videojs/video.js#8367 in https://github.com/videojs/video.js referencing this one, since that is where the ultimate fix would need to be deployed
  • We are still trying to figure out why we are getting VTT files mac classic CR line endings, and have a workaround by locally modifying files to fix the regex. But an official build would of course be better.

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

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

if (!/\r\n|\n/.test(self.buffer)) {
that looks like it needs an \r test.