CC: | c.deignan [...] rsd.com |
Subject: | leaving end boundary without \n |
Hi Gisle,
In HTTP::Message, when you parse multiparts, You use this: (around line
1000)
$str =~ s/\r?\n--\Q$b\E--\r?\n.*//s;
if ($str =~ s/(^|.*?\r?\n)--\Q$b\E\r?\n//s) {
$self->{_parts} = [map HTTP::Message->parse($_).
split(/\r?\n--\Q$b\E\r?\n/, $str)]
}
According to RFC2046 section 5.1.1 page 19:
--gc0pJq0M:08jU534c0p--
NOTE TO IMPLEMENTORS: Boundary string comparisons must compare the
boundary value with the beginning of each candidate line. An exact
match of the entire candidate line is not required; it is sufficient
that the boundary appear in its entirety following the CRLF.
It is a bit hard to read, but I (and some implementation) read this as:
there doesn't need to be a \n after the -- of the closing boundary. The
regex is therefore to strict, requiring an \n
- $str =~ s/\r?\n--\Q$b\E--\r?\n.*//s;
+ $str =~ s/\r?\n--\Q$b\E--.*//s;
[[ side note: I think OO likes to see HTTP::Message->parse($_)
to be rewritten als (ref $self)->parse($_)
]]
Thanks in advance, MarkOv