summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2012-08-29 13:06:58 +0000
committerJo-Philipp Wich <jow@openwrt.org>2012-08-29 13:06:58 +0000
commitc4d0dd19b7b88c6bcbd1bb1b052d61283025a149 (patch)
treeeefec6551a8460995bae405ce939e8201d1e5ee7
parentec5487649e426957370a1dc30aacd32fb57ad691 (diff)
libs/web: merge luci.http.protocol fix from Fonosfera
See http://trac.fonosfera.org/fon-ng/changeset/2102/trunk/luci/libs/http .
-rw-r--r--libs/web/luasrc/http/protocol.lua22
1 files changed, 10 insertions, 12 deletions
diff --git a/libs/web/luasrc/http/protocol.lua b/libs/web/luasrc/http/protocol.lua
index d8ef09f7a..0d41550b2 100644
--- a/libs/web/luasrc/http/protocol.lua
+++ b/libs/web/luasrc/http/protocol.lua
@@ -434,23 +434,21 @@ function mimedecode_message_body( src, msg, filecb )
until not spos
if found then
- if #data > 78 then
- lchunk = data:sub( #data - 78 + 1, #data )
- data = data:sub( 1, #data - 78 )
-
- if store then
- store( field, data, false )
- else
- return nil, "Invalid MIME section header"
- end
- else
- lchunk, data = data, nil
- end
+ -- We found at least some boundary. Save
+ -- the unparsed remaining data for the
+ -- next chunk.
+ lchunk, data = data, nil
else
+ -- There was a complete chunk without a boundary. Parse it as headers or
+ -- append it as data, depending on our current state.
if inhdr then
lchunk, eof = parse_headers( data, field )
inhdr = not eof
else
+ -- We're inside data, so append the data. Note that we only append
+ -- lchunk, not all of data, since there is a chance that chunk
+ -- contains half a boundary. Assuming that each chunk is at least the
+ -- boundary in size, this should prevent problems
store( field, lchunk, false )
lchunk, chunk = chunk, nil
end