from urllib.parse import urlparse
malformed = urlparse("8.8.8.8:1337")._replace(scheme='http').geturl()
print(malformed)
This prints ''http:///8.8.8.8:1337", but should have printed "http://8.8.8.8:1337".
Note the three slashes.
The reason is that the urlunsplit function in Lib/urllib/parse.py checks whether the original url contains a slash, which is not the case, adds a slash and then adds two more slashes.
MKCompu commentedNov 30, 2022
•
edited by bedevere-bot
Bug report
This prints ''http:///8.8.8.8:1337", but should have printed "http://8.8.8.8:1337".
Note the three slashes.
The reason is that the urlunsplit function in Lib/urllib/parse.py checks whether the original url contains a slash, which is not the case, adds a slash and then adds two more slashes.
Your environment
Linked PRs
The text was updated successfully, but these errors were encountered: