--- /home/max/httpd-2.4.33/modules/lua/lua_request.c 2017-07-05 00:28:38.000000000 +0200 +++ /home/max/httpd-2.4.33/modules/lua/lua_request.c 2018-05-10 18:47:32.491293762 +0200 @@ -46,6 +46,40 @@ typedef int (*req_field_int_f) (request_rec * r); typedef req_table_t *(*req_field_apr_table_f) (request_rec * r); +static void +argstr_to_table(char *str, apr_table_t *parms) +{ + char *key; + char *value; + char *strtok_state; + + if (str == NULL) { + return; + } + + key = apr_strtok(str, "&", &strtok_state); + while (key) { + value = strchr(key, '='); + if (value) { + *value = '\0'; /* Split the string in two */ + value++; /* Skip passed the = */ + } + else { + value = "1"; + } + ap_unescape_url(key); + ap_unescape_url(value); + apr_table_add(parms, key, value); + key = apr_strtok(NULL, "&", &strtok_state); + } +} + +AP_DECLARE(void) ap_lua_args_to_table(request_rec *r, apr_table_t **table) +{ + apr_table_t *t = apr_table_make(r->pool, 10); + argstr_to_table(apr_pstrdup(r->pool, r->args), t); + *table = t; +} void ap_lua_rstack_dump(lua_State *L, request_rec *r, const char *msg) { @@ -314,7 +348,7 @@ request_rec *r = ap_lua_check_request_rec(L, 1); lua_newtable(L); lua_newtable(L); /* [table, table] */ - ap_args_to_table(r, &form_table); + ap_lua_args_to_table(r, &form_table); apr_table_do(req_aprtable2luatable_cb, L, form_table, NULL); return 2; /* [table, table>] */ } @@ -497,7 +531,7 @@ const char *name = luaL_checkstring(L, 2); ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01485) "adding output filter %s", name); - ap_add_output_filter(name, L, r, r->connection); + ap_add_output_filter(name, NULL, r, r->connection); return 0; }