[issue10860] urllib2 crashes on valid URL

2011-01-08 Thread Senthil Kumaran

Senthil Kumaran orsent...@gmail.com added the comment:

On Fri, Jan 07, 2011 at 07:14:30PM +, Shawn Ligocki wrote:
 
 I think the problem is that http://118114.cn; says it redirects to
 http://www.118114.cn:;, but it seems like urllib2 should be able to
 deal with that or at least report back a more useful error message.

I think, this is improper at the Server End to redirect it to URL
where ':' is provided and Port is missing.

Any client, which does a transparent redirection, can be expected to fail.

sent...@rubuntu:~$ curl -L http://118114.cn
curl: (6) Couldn't resolve host 'www.118114.cn:'

The Redirected URL is an Invalid Syntax and I don't think we should
fix by providing a default port at urllib2 end. What can be done is
fail with timeout or raise an Exception for an Invalid URL.

--
title: Handle empty port after port delimiter in httplib - urllib2 crashes on 
valid URL

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10860
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10860] urllib2 crashes on valid URL

2011-01-07 Thread Shawn Ligocki

New submission from Shawn Ligocki sligo...@gmail.com:

urllib2 crashes with stack trace on legal URL http://118114.cn

Transcript:

Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) 
[GCC 4.4.3] on linux2
Type help, copyright, credits or license for more information.
 import urllib2
 urllib2.urlopen(http://118114.cn;)
Traceback (most recent call last):
  File stdin, line 1, in module
  File /usr/lib/python2.6/urllib2.py, line 126, in urlopen
return _opener.open(url, data, timeout)
  File /usr/lib/python2.6/urllib2.py, line 397, in open
response = meth(req, response)
  File /usr/lib/python2.6/urllib2.py, line 510, in http_response
'http', request, response, code, msg, hdrs)
  File /usr/lib/python2.6/urllib2.py, line 429, in error
result = self._call_chain(*args)
  File /usr/lib/python2.6/urllib2.py, line 369, in _call_chain
result = func(*args)
  File /usr/lib/python2.6/urllib2.py, line 605, in http_error_302
return self.parent.open(new, timeout=req.timeout)
  File /usr/lib/python2.6/urllib2.py, line 391, in open
response = self._open(req, data)
  File /usr/lib/python2.6/urllib2.py, line 409, in _open
'_open', req)
  File /usr/lib/python2.6/urllib2.py, line 369, in _call_chain
result = func(*args)
  File /usr/lib/python2.6/urllib2.py, line 1161, in http_open
return self.do_open(httplib.HTTPConnection, req)
  File /usr/lib/python2.6/urllib2.py, line 1107, in do_open
h = http_class(host, timeout=req.timeout) # will parse host:port
  File /usr/lib/python2.6/httplib.py, line 657, in __init__
self._set_hostport(host, port)
  File /usr/lib/python2.6/httplib.py, line 682, in _set_hostport
raise InvalidURL(nonnumeric port: '%s' % host[i+1:])
httplib.InvalidURL: nonnumeric port: ''
 


I think the problem is that http://118114.cn; says it redirects to 
http://www.118114.cn:;, but it seems like urllib2 should be able to deal with 
that or at least report back a more useful error message.

$ nc 118114.cn 80
GET / HTTP/1.1
Host: 118114.cn   
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) 
Gecko/20101206 Ubuntu/10.04 (lucid) Firefox/3.6.13

HTTP/1.1 301 Moved Permanently
Server: nginx/0.7.64
Date: Fri, 07 Jan 2011 19:06:32 GMT
Content-Type: text/html
Content-Length: 185
Connection: keep-alive
Keep-Alive: timeout=60
Location: http://www.118114.cn:

html
headtitle301 Moved Permanently/title/head
body bgcolor=white
centerh1301 Moved Permanently/h1/center
hrcenternginx/0.7.64/center
/body
/html

--
components: Library (Lib)
messages: 125687
nosy: sligocki
priority: normal
severity: normal
status: open
title: urllib2 crashes on valid URL
type: crash
versions: Python 2.6

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10860
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10860] urllib2 crashes on valid URL

2011-01-07 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Thanks for the report.  Can you test it with current versions (2.7, 3.1 or 3.2)?

--
nosy: +eric.araujo, orsenthil
versions: +Python 2.7, Python 3.1, Python 3.2 -Python 2.6

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10860
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com