twill http equiv-refresh fix

September 20, 2008 – 02:05

Just have blogged that twill bugs me. So here’s the fix. As always, dead simple to locate the guilty and patch it.

If you’ll open twill/utils.py and scroll down to the line 408, you’ll find equiv-refresh header parsing code.

Here are the guilty lines:

            j = newurl_spec.find("=")
            if j != -1:
                newurl = newurl_spec[j+1:]
            else:
                newurl = newurl_spec

Of course, if url contains a parameter just like /there/is/path/?key=something, twill happily mangles the url.

The correct code is:

            j = newurl_spec.find("url=")
            if j != -1:
                newurl = newurl_spec[j+len('url='):]
            else:
                newurl = newurl_spec

When I’ll find a twill git or svn, I’ll create a patch.