Subject Author Date
Re: Decoding bug (and fix) for multipart/form-data ? Martin Stjernholm <mast[at]roxen[dot]com> 21-03-2009
"Stephen R. van den Berg" <<srb[at]>> wrote:

> Well, that's what the RFC says perhaps, but that is not what
> Firefox/MSIE/Opera do.

Ok, I see.

> I haven't observed a browser actually submitting a charset, though I
> admit I didn't look too closely at what Opera provides (and haven't
> tested Safari yet, nor MSIE8). But I could/should support this
> situation of course.

Yes, if it's there, it should be heeded.

> Yes, but since the browser behaviour violates the standards to begin
> with, what can you do?

Indeed. I guess the best way is to solve it is just like the same mess
in the query variables is handled by RequestID.decode_query. That's
basically what your code does, but for clarity I refactored it to use
the same decoding phase as the other cases.

> I would guess that they start pointing fingers at Microsoft, and Microsoft
> will point back to Mozilla, all in the name of (bug-)compatibility, and
> probably laziness (the multipart form stuff is complicated enough that
> nobody actually dared to touch the code, I'd wager).

In this case it looks more like laziness to me, since I find it
difficult to believe that the server implementations are broken to the
point that they get confused by an extra line in the header section,
also considering the fact that that extra line does get included for

It's also kinda odd that the net doesn't discuss this at all. I've
found some stray references to how e.g. Firefox can send
multipart/form-data which is defined in rfc 2388, but noone seems to
have noticed that it really doesn't. Am I the only one in the world
that gets somewhat bothered by the fact that seemingly all
implementations blatantly disobeys a 10 year old rfc?

>>The fun doesn't stop with the charsets, for that matter. The rfc and
>>the html standard says that multiple file responses should be encoded
>>as multipart/mixed within multipart/form-data. /.../
> I didn't test this, since it's a rather silly use case (I think), but it
> should be possible to accomodate at the Roxen/Pike end.

After a more careful read I can say that multipart/mixed should be
used for all entries with multiple values, not just files. So it's not
a quite so marginal use case. But I agree the standard is sillier than
the de-facto behavior on that point.