-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Incorrect appending of stringUri when baseUri contains a query string #327
Comments
You're right in saying that the result isn't correct, but I don't think your result is correct either. According to RFC3986, I think the following are true:
So I think the correct result for your example is:
Which is in line with the 2nd example in section 5.4.1 of the spec. We should fix the implementation, but doing so wont solve your case. If you're actually trying to merge URLs in the form you gave in your example, then I think you'll need to change the way you're specifying them in your manifests so that they merge properly according to the spec. I think you'd probably need to do something more like the 6th example in 5.4.1. For example:
Which would merge in the way you expect. |
Agree with ojw28. In fact, adding query string parameters of the base url will cause issues when working with some CDN's, that offer some security mechanisms that are based on a query string parameter that must be included just in the master request. |
@ojw28 Thanks for the explanation. For your second bullet point, if we were to reformat our manifest to follow the 5.4.1 example 6, (i.e. baseUri = https://foobar.com/video/ABCD1234), would the merge be correct with the current ExoPlayer master branch logic or would we still have to wait for a fix? Is there any combination that would give the expected merged URI with the current implementation? |
@ojw28, in my humble opinion I don't think implementing remove_dot_segments is an urgent need. I don't know any CDN, media server or encoder that is producing HLS streams whose segments/media playlists/encryption urls are defined using "../" or "./" (much less using other character combinations like /../ or /./). And, as you said, in 99.9% of cases this is going to be supported directly by the web server receiving the requests. However, strictly speaking we should implement that also in the client/player side. The good point is we don't need to reinvent the wheel, this is a very known piece of code (that is even part of Android source code). See canonicalizePath method here: https://android.googlesource.com/platform/libcore/+/9b510df35b57946d843ffc34cf23fdcfc84c5220/luni/src/main/java/libcore/net/url/UrlUtils.java So, given how easy this would be, my two cents go to adding this. Not something urgent, but a task for the future. |
@phpeng-ms I think that would work correctly with the current version of ExoPlayer, yes. |
@jeoliva Thanks for the link! I have a change I'm working on that correctly resolves for all normal and abnormal cases in the RFC, which is a good sign. I hope to push tomorrow, although it might take another day. |
When
baseUri
contains a query string, thestringUri
component is incorrectly appended. This is becauseUtil.getMergedUri(baseUri, stringUri)
callsUri.withAppendedPath(baseUri, stringUri)
, which addsstringUri
as an additional path, then appends the original query frombaseUri
to the end. The expected behaviour should be a straight concatenation ofstringUri
to the end ofbaseUri
.For example, given:
baseUri = https://foobar.com/video/ABCD1234?videoformat=dash&
stringUri = quality=video360p&time=0
The expected URI would be:
https://foobar.com/video/ABCD1234?videoformat=dash&quality=video360p&time=0
The current (incorrect) URI is:
https://foobar.com/video/ABCD1234/quality=video360p&time=0?videoformat=dash&
The following is a temporary special-case patch to handle this case. A proper fix would be better.
The text was updated successfully, but these errors were encountered: