mirror of
https://github.com/rutgersc/m3u8-rs.git
synced 2024-11-15 21:21:08 +00:00
Handle blank lines when checking for master playlist tags.
Fix a bug where a blank line in a master playlist before the first master playlist tag will make the parser think it's a media playlist. Fixes #17
This commit is contained in:
parent
76aab26b20
commit
978e6a7e58
2 changed files with 13 additions and 2 deletions
10
sample-playlists/master-playlist-with-blankline.m3u8
Normal file
10
sample-playlists/master-playlist-with-blankline.m3u8
Normal file
|
@ -0,0 +1,10 @@
|
|||
#EXTM3U
|
||||
|
||||
#EXT-X-STREAM-INF:BANDWIDTH=1280000,AVERAGE-BANDWIDTH=1000000
|
||||
http://example.com/low.m3u8
|
||||
#EXT-X-STREAM-INF:BANDWIDTH=2560000,AVERAGE-BANDWIDTH=2000000
|
||||
http://example.com/mid.m3u8
|
||||
#EXT-X-STREAM-INF:BANDWIDTH=7680000,AVERAGE-BANDWIDTH=6000000
|
||||
http://example.com/hi.m3u8
|
||||
#EXT-X-STREAM-INF:BANDWIDTH=65000,CODECS="mp4a.40.5"
|
||||
http://example.com/audio-only.m3u8
|
|
@ -85,7 +85,7 @@ pub mod playlist;
|
|||
|
||||
use nom::character::complete::{digit1, multispace0, space0 };
|
||||
use nom::{IResult};
|
||||
use nom::{ delimited,none_of,peek,is_not,complete,terminated,tag,
|
||||
use nom::{ delimited,none_of,peek,is_a,is_not,complete,terminated,tag,
|
||||
alt,do_parse,opt,named,map,map_res,eof,many0,take,take_until,char};
|
||||
use nom::combinator::map;
|
||||
use nom::character::complete::{line_ending};
|
||||
|
@ -222,7 +222,8 @@ pub fn contains_master_tag(input: &[u8]) -> Option<(bool, String)> {
|
|||
|
||||
named!(pub is_master_playlist_tag_line(&[u8]) -> Option<(bool, String)>,
|
||||
do_parse!(
|
||||
tag: opt!(alt!(
|
||||
opt!(is_a!("\r\n"))
|
||||
>> tag: opt!(alt!(
|
||||
map!(tag!("#EXT-X-STREAM-INF"), |t| (true, t))
|
||||
| map!(tag!("#EXT-X-I-FRAME-STREAM-INF"), |t| (true, t))
|
||||
| map!(terminated!(tag!("#EXT-X-MEDIA"), is_not!("-")), |t| (true, t)) // terminated!() to prevent matching with #EXT-X-MEDIA-SEQUENCE for which we have a separate pattern below
|
||||
|
|
Loading…
Reference in a new issue