[mod_python] HTTP mime header decoding

Graham Dumpleton graham.dumpleton at gmail.com
Tue Jul 28 21:42:31 EDT 2009

2009/7/29 Philip Scott <Philip.Scott at cantabcapital.com>:
> Hi all,
> I was intending to post this to the -dev list, but it appears to have moved
> somewhere I cannot find it, so hopefully this email will find the right
> eyes.

No matter where you sent it, no one is actively developing or
maintaining mod_python.

All you can do is go to:


and log a description of the problem and the proposed patch and if
valid hope it may be addressed one day.

There are other unresolved bug reports about stuff in that same
section of code, but I believe they are for different issues.


> I recently upgraded our mod_python from an old version (circa 2004) to the
> latest and greatest Ubuntu had to offer, and unfortunately this caused a bit
> of a regression in our system. We have to interface with a rather obscure
> client, which sends its data through a HTTP POST request as a multipart
> message separated nicely with boundaries, but which does not add a new line
> or carriage return after the final boundary. I am not sure whether this is
> permitted in the standard, but it worked in the old version - I think some
> changes to improve multi-line handling (adding the use of a boundary regex)
> upset this.
> I have a very small patch for util.py which fixes this on my end, and I
> think should be benign. If someone in the know would like to check it won't
> have any unintended side effects, it would be great to stick it in the tree;
> perhaps there are some more obscure clients that do this as well?
> --- util.py.orig        2009-07-28 16:08:00.000000000 +0100
> +++ util.py     2009-07-28 16:08:19.000000000 +0100
> @@ -237,7 +237,7 @@
>              boundary = ctype[i+9:]
>              if len(boundary) >= 2 and boundary[0] == boundary[-1] == '"':
>                  boundary = boundary[1:-1]
> -            boundary = re.compile("--" + re.escape(boundary) +
> "(--)?\r?\n")
> +            boundary = re.compile("--" + re.escape(boundary) +
> "(--)?\r?\n?")
>          except ValueError:
>              raise apache.SERVER_RETURN, apache.HTTP_BAD_REQUEST
> I think that since we get the line we compare to boundary using readline()
> anyway, it is safe to make the final \n optional. It certainly appears to
> work..
> Thanks,
> Philip
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python

More information about the Mod_python mailing list