hlua_channel_append() inserts the string at the offset of the start of the
input data, like hlua_channel_prepend() does, instead of after the existing
input data. The offset+len expression is computed and passed through
hlua_channel_filter() but never used. The function is otherwise identical to
hlua_channel_prepend(), it seems to be a copy-paste mistake when the
filter-aware insert path was introduced; hlua_http_msg_append() correctly
inserts at offset+len for the same operation.
As a result, Channel.append() behaved exactly like Channel.prepend(),
placing the string in front of the channel's input data instead of at its
end, in contradiction with its documentation ("Same as
Channel.insert(channel, string, channel:input())").
This patch should fix the issue #3598. It must be backported to all
supported versions.
if (filter && !hlua_filter_from_payload(filter, chn))
WILL_LJMP(lua_error(L));
- ret = _hlua_channel_insert(chn, L, ist2(str, sz), offset);
+ ret = _hlua_channel_insert(chn, L, ist2(str, sz), offset+len);
if (ret > 0 && filter) {
struct hlua_flt_ctx *flt_ctx = filter->ctx;