libs/web: merge luci.http.protocol fix from Fonosfera
See http://trac.fonosfera.org/fon-ng/changeset/2102/trunk/luci/libs/http .
This commit is contained in:
parent
ec5487649e
commit
c4d0dd19b7
1 changed files with 10 additions and 12 deletions
|
@ -434,23 +434,21 @@ function mimedecode_message_body( src, msg, filecb )
|
||||||
until not spos
|
until not spos
|
||||||
|
|
||||||
if found then
|
if found then
|
||||||
if #data > 78 then
|
-- We found at least some boundary. Save
|
||||||
lchunk = data:sub( #data - 78 + 1, #data )
|
-- the unparsed remaining data for the
|
||||||
data = data:sub( 1, #data - 78 )
|
-- next chunk.
|
||||||
|
|
||||||
if store then
|
|
||||||
store( field, data, false )
|
|
||||||
else
|
|
||||||
return nil, "Invalid MIME section header"
|
|
||||||
end
|
|
||||||
else
|
|
||||||
lchunk, data = data, nil
|
lchunk, data = data, nil
|
||||||
end
|
|
||||||
else
|
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
|
if inhdr then
|
||||||
lchunk, eof = parse_headers( data, field )
|
lchunk, eof = parse_headers( data, field )
|
||||||
inhdr = not eof
|
inhdr = not eof
|
||||||
else
|
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 )
|
store( field, lchunk, false )
|
||||||
lchunk, chunk = chunk, nil
|
lchunk, chunk = chunk, nil
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue