This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: urllib2 should be more robust for sloppy proxy URLs
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: doko, georg.brandl, lordsutch, spiv
Priority: normal Keywords:

Created on 2004-02-22 10:05 by doko, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
urllib2.diff doko, 2004-03-28 13:28
Messages (5)
msg20104 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2004-02-22 10:05
passing an URL like "foo.bar.baz" instead of
"http://foo.bar.baz" results in a stacktrace:

  File "/usr/lib/python2.3/urllib2.py", line 326, in open
    '_open', req)
  File "/usr/lib/python2.3/urllib2.py", line 306, in
_call_chain
    result = func(*args)
  File "/usr/lib/python2.3/urllib2.py", line 491, in
<lambda>
    lambda r, proxy=url, type=type, meth=self.proxy_open: \
  File "/usr/lib/python2.3/urllib2.py", line 498, in
proxy_open
    if '@' in host:
TypeError: iterable argument required

This could be fixed by calling urlparse.urlparse on the
proxy url, either in the calling code or in the library
code, which I would prefer to make it more robust about
sloppy URLs passed in the http_proxy environment variable.
msg20105 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2004-02-22 10:19
Logged In: YES 
user_id=60903

Ok, I see, PEP42 ...
msg20106 - (view) Author: Chris Lawrence (lordsutch) Date: 2004-03-24 21:51
Logged In: YES 
user_id=6757

I've put together a patch, which can be found at
http://bugs.debian.org/233305; it isn't perfect (ideally the
entire routine should be rewritten, as it's processing
environment data that could be from the "wild"), but it
avoids the traceback.
msg20107 - (view) Author: Andrew Bennetts (spiv) Date: 2006-01-17 03:04
Logged In: YES 
user_id=50945

I think test cases would help the patch at
http://bugs.debian.org/233305 get applied.
msg20108 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-01-21 07:22
Logged In: YES 
user_id=1188172

I committed a fix (similar to the patch) in rev. 42133 to
the HEAD.

I'm not sure whether to backport.
History
Date User Action Args
2022-04-11 14:56:02adminsetgithub: 39972
2004-02-22 10:05:18dokocreate