Public bug reported:

Binary package hint: python-mechanize

mechanize.Browser will fail if Content-type header is not provided. This
situation may occur when HTTP response code is, like in the case below,
301 (Moved Permanently). In fact, the header parser shouldn't be asking
for the Content-type header if the return status code is 301 (this might
also apply to other return codes).

An example of how this can fail is listed below:

>>> url = 
>>> 'https://www.etracker.de/rdirect.php?et=qGEuhb&et_cid=1873&et_lid=264573&et_sub=vacancy_DUS_GWT&et_url=http%3A//www.airberlin.com/site/abvakanz_c.php%3FLANG%3Dspa%26MARKT%3DES%26VON%3DDUS%26NACH%3DGWT%26TAG%3D14%26MONAT%3D03%26JAHR%3D09%26WAEHRUNG%3DEUR%26ONEWAY%3DONEWAY'
>>> from mechanize import Browser
>>> b.set_handle_robots(False)
>>> b.open(url)

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/mechanize/_mechanize.py", line 203, in 
open
    return self._mech_open(url, data)
  File "/usr/lib/python2.5/site-packages/mechanize/_mechanize.py", line 229, in 
_mech_open
    response = UserAgentBase.open(self, request, data)
  File "/usr/lib/python2.5/site-packages/mechanize/_opener.py", line 192, in 
open
    response = meth(req, response)
  File "/usr/lib/python2.5/site-packages/mechanize/_http.py", line 300, in 
http_response
    if is_html(ct_hdrs, url, self._allow_xhtml):
  File "/usr/lib/python2.5/site-packages/mechanize/_headersutil.py", line 40, 
in is_html
    ct = ct[0][0][0]
IndexError: list index out of range

Environment information:

Ubuntu release:
$ lsb_release -rd
Description:    Ubuntu 8.10
Release:        8.10

$ apt-cache policy python-mechanize
python-mechanize:
  Installed: 0.1.7b-2
  Candidate: 0.1.7b-2
  Version table:
 *** 0.1.7b-2 0
        500 http://is.archive.ubuntu.com intrepid/main Packages
        100 /var/lib/dpkg/status

** Affects: python-mechanize (Ubuntu)
     Importance: Undecided
         Status: New

-- 
mechanize.Browser breaks when Content-type header is not supplied
https://bugs.launchpad.net/bugs/317440
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to