download_strategy: ignore query strings when parsing resolved URLs #13110
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
An alternative to #13108 for fixing Homebrew/homebrew-cask#121725, but I think it makes sense to make both changes.
We currently parse query strings
https://example.com/download.php?file=foo-1.0.tar.gz
to extract the file extension.This is not always correct. Sometimes you have scenarios like
https://example.com/file=foo-1.0.tar.gz?host=elsewhere.com
where it'll thinkelsewhere.com
is the basename.It's impossible to tell really how a URL should be parsed, so what I've done is alter the behaviour of URL parsing in the scenario where we've already followed redirects and checked headers. This means we have checked for and did not find a
Content-Disposition
so we are safe to follow what browsers do: take the basename, ingoring the query string.Keep the original behaviour for the "dumber" scan-the-unresolved-URL case (i.e. the URL direct from the formula and cask), which is less likely to have crazy query strings at the end of the URL.