m3u8-parser icon indicating copy to clipboard operation
m3u8-parser copied to clipboard

Report error for non-quoted attribute strings

Open gregfr opened this issue 8 years ago • 2 comments

Greetings I'm using VideoJS with HLS and I'm receiving exceptions for this line:

attr = (/([^=]*)=(.*)/).exec(attrs[i]).slice(1);

(parse-stream.js line 40)

The problem is, the attribute array is like this:

1:"PROGRAM-ID=1"
2:""
3:"BANDWIDTH=650000"
4:""
5:"RESOLUTION=600x356"
6:""
7:"CODECS=avc1.66.31"
8:",mp4a.40.2"

probably because it's parsed from a m3u8 manifest.

On the first line parsed, line 8, the regex returns undefined so there is no slice() method.

I'm not sure if parseAttributes() should be receiving this, but it definitely should check the regex result before using it.

gregfr avatar Sep 12 '17 08:09 gregfr

BTW the error is initially due to a bad manifest (lack of quote) but many sources online use it.

gregfr avatar Sep 12 '17 09:09 gregfr

The spec (https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#page-29) indicates that CODECS are defined as a quoted string. In the future we will add validation warnings and errors to indicate that a manifest is not to spec, at the moment we don't have plans to handle bad manifests.

Keeping this open until we've implemented the validation warning

forbesjo avatar Sep 26 '18 20:09 forbesjo