Skip to content

Commit

Permalink
Added check that parameter name matches fully
Browse files Browse the repository at this point in the history
  • Loading branch information
olekhov authored and mauricioabreu committed Aug 6, 2024
1 parent 91c3982 commit 1b19289
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
3 changes: 3 additions & 0 deletions m3u8/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,9 @@ def _parse_attribute_list(prefix, line, attribute_parser, default_parser=None):
params = ATTRIBUTELISTPATTERN.split(line.replace(prefix + ":", ""))[1::2]

attributes = {}
if not line.startswith(prefix+':') :
return attributes

for param in params:
param_parts = param.split("=", 1)
if len(param_parts) == 1:
Expand Down
16 changes: 14 additions & 2 deletions tests/playlists.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,19 @@
http://media.example.com/fileSequence52-3.ts
"""

PLAYLIST_WITH_SESSION_ENCRYPTED_SEGMENTS = """
PLAYLIST_WITH_CUSTOM_MEDIA_HEADER = '''#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:6
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-MEDIA-READY:7f659f6f09bce196d7
#EXT-X-KEY:METHOD=AES-128,URI="[KEY]",IV=[IV]
#EXTINF:6.0,
https://cdn.example.com/vod/hash:XXX/file.mp4/media-1.ts
#EXTINF:6.28,
https://cdn.example.com/vod/hash:XXX/file.mp4/media-2.ts
'''

PLAYLIST_WITH_SESSION_ENCRYPTED_SEGMENTS = '''
#EXTM3U
#EXT-X-MEDIA-SEQUENCE:7794
#EXT-X-TARGETDURATION:15
Expand All @@ -111,7 +123,7 @@
http://media.example.com/fileSequence52-2.ts
#EXTINF:15,
http://media.example.com/fileSequence52-3.ts
"""
'''

VARIANT_PLAYLIST = """
#EXTM3U
Expand Down
4 changes: 4 additions & 0 deletions tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,10 @@ def test_session_key_attribute_without_initialization_vector():
assert None is obj.session_keys[0].iv


def test_parse_custom_media_header():
obj = m3u8.M3U8(playlists.PLAYLIST_WITH_CUSTOM_MEDIA_HEADER)


def test_segments_attribute():
obj = m3u8.M3U8(playlists.SIMPLE_PLAYLIST)
mock_parser_data(
Expand Down

0 comments on commit 1b19289

Please sign in to comment.