Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added check that parameter name matches fully #201

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

olekhov
Copy link

@olekhov olekhov commented Apr 14, 2020

Hello.
I've encountered m3u8 playlist with custom header:
#EXT-X-MEDIA-READY:7f659f6f09bce196d7
This header is erroneously parsed as #EXT-X-MEDIA header and gives this error:
ValueError: not enough values to unpack (expected 2, got 1)
at parser.py: 275

I think you should check that parameter string starts with exact parameter name, not just part of it.
Here is PR that fixes this.
test is also provided.

@@ -86,6 +86,18 @@
http://media.example.com/fileSequence52-3.ts
'''

PLAYLIST_WITH_CUSTOM_MEDIA_HEADER = '''#EXTM3U
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can name it PLAYLIST_WITH_CUSTOM_TAG because your code fixes every custom tag, not just EXT-X-MEDIA. Do you agree?

@@ -273,6 +273,10 @@ def test_session_key_attribute_without_initialization_vector():
assert None == obj.session_keys[0].iv


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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should expect this test to assert something. I get it does not break, but what happens with the EXT-X-MEDIA-READY? Does it go away? Does it get parsed?

@@ -271,6 +271,9 @@ def _parse_attribute_list(prefix, line, atribute_parser):
params = ATTRIBUTELISTPATTERN.split(line.replace(prefix + ':', ''))[1::2]

attributes = {}
if not line.startswith(prefix+':') :
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! Could you remove that extra black space before the last colon?

@davemevans davemevans mentioned this pull request Apr 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants