-
Notifications
You must be signed in to change notification settings - Fork 474
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
Re-work URL joining to follow RFC 3986 #316
Conversation
@@ -15,7 +15,6 @@ | |||
http://stackoverflow.com/questions/2785755/how-to-split-but-ignore-separators-in-quoted-strings-in-python | |||
''' | |||
ATTRIBUTELISTPATTERN = re.compile(r'''((?:[^,"']|"[^"]*"|'[^']*')+)''') | |||
URI_PREFIXES = ('https://', 'http://', 's3://', 's3a://', 's3n://') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change allows playlists to use additional URL schemes without having to update this list. RFC 8216 does mention at least the data://
scheme.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! You remove a line while adding a new feature 👏🏼
@@ -42,7 +42,7 @@ def test_load_should_create_object_from_file_with_relative_segments(): | |||
obj = m3u8.load(playlists.RELATIVE_PLAYLIST_FILENAME) | |||
expected_key_abspath = '%s/key.bin' % os.path.dirname(base_uri) | |||
expected_key_path = '../key.bin' | |||
expected_ts1_abspath = '%s/entire1.ts' % base_uri | |||
expected_ts1_abspath = '/entire1.ts' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think files with a leading /
were being mis-handled as well.
On a file system, joining /tmp/path/to/somewhere
with /entire.ts
should produce /entire.ts
.
>>> from os.path import join as python_join
>>> python_join('/path/to/somewhere', '/entire1.ts')
'/entire1.ts'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed
Greatly surprised. So, |
@SeaHOH maybe Windows paths? |
I think it's fine to use |
A HTTP URL, just like this: |
Yes, I just told what I have saw, and be curious about how does it work with web player. |
This PR updates how the
absolute_uri
method for objects that use theBasePathMixin
.I think the changes related to issue #245 and PR #263 introduced some unusual and surprising behavior. The issue related to handling relative URLs that start with
//
, like//segment.ts
.Joining URLs is covered by RFC 3986, which specifically describes the
//
case. From section 5.4.1:Python's built-in
urllib.parse.urljoin
produces the expected result, butm3u8.parse.urljoin
does not:This PR updates
m3u8
to prefer the standards-based approach.