Fix host component handling in file:// URLs #2342
Merged
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.
pkg handles file:// URLs in libpkg/fetch_file.c which translates the file URL into an access to the local filesystem. Ignoring the host component altogether in this process is semantically wrong. The host component, if given, directs the file to be fetched from that host, not from the local filesystem.
Extend the handling of the host component to accept the localhost host component - the null host component file:/// is anyway accepted already, but reject any other host component, as the code is not intended to go around looking for files on other hosts.
Update the test cases for the changed error message (invalid URL), as well as add a test case for accepting file://localhost/path URL.
closes #2339