-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Fix the URL quoting in _clean_link() for IPv6 addresses #6245
Conversation
2fe0cec
to
15f17db
Compare
Replacing hand-craft URL escaping with stdlib calls is almost always the right thing to do. +1 to this with one small request in implementation. |
15f17db
to
2719971
Compare
Do you want me to do anything else for this PR @uranusjr ? |
Do you know why CI is failing? It would be most ideal if we can get a green tick. Also I think this change needs to appear in the changlog, instead of being classified as trivial. |
cda40bf
to
910e3e9
Compare
I updated the news item. I will have a look at the CI failure. I don't have Windows so hopefully I can get something out of the console output 😃 |
Hey @nicolasbock! Did you manage to take a look at the CI failure? |
@pradyunsg Yes, but I haven't been able to make a lot of progress on it. Since I don't have access to Windows I can't reproduce the issue to troubleshoot. Do you have a suggestion as to how to go about this? |
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.
Some comments.
tests/unit/test_url.py
Outdated
_clean_path) | ||
|
||
|
||
def test_ipv4_clean_link(): |
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.
Rather than making a separate test for each test case, it would be better to use @pytest.mark.parametrize()
. Then each test case can simply be an additional argument to parametrize()
.
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.
Done. I am still using two extra variables, _path
and _clean_path
. Is that appropriate? Or should I fold that into the arguments for the decorator?
Also, I'm not completely sure, but maybe the Windows failure is in part because the PR causes the
|
a310119
to
9520258
Compare
That's a good point. I will have a look into how to parse a Windows path. Presumably |
I added a Windowsish path to the test. Note that at this point this is expected to fail. |
@cjerdonek I think I got it now. The test is passing for me. However, since there is no check whether |
@nicolasbock That looks good. That's what I meant. For the few test cases where the test expectation will be platform-dependent, the way I would do it is break those few cases off into |
Thanks for the hint @cjerdonek . I have split the one test into two as you suggested. Let's see if I got the test conditions for Windows right this time 😄. |
Looking through the code base, the pattern I see being used is this--
(or |
Isn't there a |
No, 64-bit Windows also identifies itself as |
Thanks @uranusjr . I adjusted the skip expressions @cjerdonek . |
@uranusjr , @pradyunsg , @cjerdonek , Any chance for another review? @pfmoore Could you check this PR on Windows again to make sure I got this right? Thanks all! |
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.
Some wording suggestions on the comments. Otherwise looks good!
When the `base_url` is a `[]` protected IPv6 address, the `_clean_link()` function converts `[` to `%5B` and `]` to `%5D`, which renders the `base_url` invalid. For example: ``` Starting new HTTP connection (1): fd00:0:0:236::100:8181 http://fd00:0:0:236::100:8181 "GET /os-releases/19.0.0.0b1/opensuse_leap-42.3-x86_64/requirements_absolute_requirements.txt HTTP/1.1" 200 None Setting setuptools==40.6.3 (from -c http://[fd00:0:0:236::100]:8181/os-releases/19.0.0.0b1/opensuse_leap-42.3-x86_64/requirements_absolute_requirements.txt (line 204)) extras to: () Looking in indexes: http://[fd00:0:0:236::100]:8181/simple Collecting setuptools==40.6.3 (from -c http://[fd00:0:0:236::100]:8181/os-releases/19.0.0.0b1/opensuse_leap-42.3-x86_64/requirements_absolute_requirements.txt (line 204)) 1 location(s) to search for versions of setuptools: * http://[fd00:0:0:236::100]:8181/simple/setuptools/ Getting page http://[fd00:0:0:236::100]:8181/simple/setuptools/ http://fd00:0:0:236::100:8181 "GET /simple/setuptools/ HTTP/1.1" 200 376 Analyzing links from page http://[fd00:0:0:236::100]:8181/simple/setuptools/ _package_versions: link = http://%5bfd00:0:0:236::100%5d:8181/packages/opensuse_leap-42.3-x86_64/setuptools/setuptools-40.6.3-py2.py3-none-any.whl#md5=389d3cd088d7afec3a1133b1d8e15df0 (from http://[fd00:0:0: 236::100]:8181/simple/setuptools/) _link_package_versions: link = http://%5bfd00:0:0:236::100%5d:8181/packages/opensuse_leap-42.3-x86_64/setuptools/setuptools-40.6.3-py2.py3-none-any.whl#md5=389d3cd088d7afec3a1133b1d8e15df0 (from http://[fd00 :0:0:236::100]:8181/simple/setuptools/) Found link http://%5bfd00:0:0:236::100%5d:8181/packages/opensuse_leap-42.3-x86_64/setuptools/setuptools-40.6.3-py2.py3-none-any.whl#md5=389d3cd088d7afec3a1133b1d8e15df0 (from http://[fd00:0:0:236::100]:8181/ simple/setuptools/), version: 40.6.3 Using version 40.6.3 (newest of versions: 40.6.3) Could not install packages due to an EnvironmentError. InvalidURL: Failed to parse: %5bfd00:0:0:236::100%5d:8181 ``` This change uses the vendored `urllib` library to split the host part off of the url before URL quoting only the path part. Fixes: pypa#6285 Signed-off-by: Nicolas Bock <[email protected]>
Thanks for the comments @cjerdonek ! I pushed another iteration incorporating your suggestions. |
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.
Looks great! Thanks for all your work and persistence on this. :) Before merging this I'll give @pfmoore another few days or so to take a look if he wants.
I'm OK with it - I'm not going to have time to have another look in the next few days, so go for it. And thanks @nicolasbock for all the work on this! |
Okay, thanks, @pfmoore! |
Thanks again, @nicolasbock! |
Thanks for you all your helpful reviews! |
This is nice! Thanks @nicolasbock for doing this and @cjerdonek, @pfmoore and @uranusjr for the reviews and inputs here. :D |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
In cases where the
base_url
is a[]
protected IPv6 address, the_clean_link()
function converts[
to%5B
and]
to%5D
, whichrenders the
base_url
invalid. For example:This change moves the
base_url
outside the_clean_link
call,leaving it unaltered.
Signed-off-by: Nicolas Bock [email protected]
Fixes: #6285