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

download_strategy: ignore query strings when parsing resolved URLs #13110

Merged
merged 1 commit into from Apr 11, 2022

Conversation

Bo98
Copy link
Member

@Bo98 Bo98 commented Apr 8, 2022

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 think elsewhere.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.

@Bo98 Bo98 added the critical Critical change which should be shipped as soon as possible. label Apr 8, 2022
@BrewTestBot
Copy link
Member

Review period skipped due to critical label.

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

No strong views on which approach we take.

Library/Homebrew/download_strategy.rb Outdated Show resolved Hide resolved
@Bo98 Bo98 merged commit 389fa42 into Homebrew:master Apr 11, 2022
@Bo98 Bo98 deleted the ignore-resolved-query branch April 11, 2022 17:23
@github-actions github-actions bot added the outdated PR was locked due to age label May 12, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
critical Critical change which should be shipped as soon as possible. outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants