Software /
code /
prosody
Comparison
net/http/parser.lua @ 5475:c2c9f07c5d6a
net.http.parser: Fix off-by-one error in chunked encoding parser
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 15 Apr 2013 21:21:57 +0100 |
parent | 5463:111953bfe767 |
child | 5477:50cbea68586f |
comparison
equal
deleted
inserted
replaced
5474:11f08a27c417 | 5475:c2c9f07c5d6a |
---|---|
131 if chunk_size == 0 and buf:find("\r\n\r\n", chunk_start-2, true) then | 131 if chunk_size == 0 and buf:find("\r\n\r\n", chunk_start-2, true) then |
132 state, chunk_size = nil, nil; | 132 state, chunk_size = nil, nil; |
133 buf = buf:gsub("^.-\r\n\r\n", ""); -- This ensure extensions and trailers are stripped | 133 buf = buf:gsub("^.-\r\n\r\n", ""); -- This ensure extensions and trailers are stripped |
134 success_cb(packet); | 134 success_cb(packet); |
135 elseif #buf - chunk_start + 2 >= chunk_size then -- we have a chunk | 135 elseif #buf - chunk_start + 2 >= chunk_size then -- we have a chunk |
136 packet.body = packet.body..buf:sub(chunk_start, chunk_start + chunk_size); | 136 print(chunk_start, chunk_size, ("%q"):format(buf)) |
137 packet.body = packet.body..buf:sub(chunk_start, chunk_start + (chunk_size-1)); | |
137 buf = buf:sub(chunk_start + chunk_size + 2); | 138 buf = buf:sub(chunk_start + chunk_size + 2); |
138 chunk_size, chunk_start = nil, nil; | 139 chunk_size, chunk_start = nil, nil; |
139 else -- Partial chunk remaining | 140 else -- Partial chunk remaining |
140 break; | 141 break; |
141 end | 142 end |