X-Git-Url: https://git.archive.openwrt.org/?a=blobdiff_plain;f=contrib%2Fpackage%2Fuhttpd%2Fsrc%2Fuhttpd-lua.c;fp=contrib%2Fpackage%2Fuhttpd%2Fsrc%2Fuhttpd-lua.c;h=b2ca34e0c1108ed3b41bbcaaa0411b17d261cac4;hb=0f18174879e121e5c5a64de0e3cb88a9c78e2b37;hp=79fb76770c0c46c0dd0b0437c22d1d567a0c2647;hpb=66ffcefa5555b35fc2e71429d9be16ac6de82801;p=project%2Fluci.git diff --git a/contrib/package/uhttpd/src/uhttpd-lua.c b/contrib/package/uhttpd/src/uhttpd-lua.c index 79fb76770..b2ca34e0c 100644 --- a/contrib/package/uhttpd/src/uhttpd-lua.c +++ b/contrib/package/uhttpd/src/uhttpd-lua.c @@ -1,6 +1,6 @@ #include "uhttpd.h" -#include "uhttpd-lua.h" #include "uhttpd-utils.h" +#include "uhttpd-lua.h" static int uh_lua_recv(lua_State *L) @@ -196,6 +196,7 @@ void uh_lua_request(struct client *cl, struct http_request *req, lua_State *L) { int i; char *query_string; + const char *prefix = cl->server->conf->lua_prefix; const char *err_str = NULL; /* put handler callback on stack */ @@ -237,12 +238,19 @@ void uh_lua_request(struct client *cl, struct http_request *req, lua_State *L) lua_pushstring(L, query_string + 1); lua_setfield(L, -2, "query_string"); - lua_pushlstring(L, req->url, (int)(query_string - req->url)); - lua_setfield(L, -2, "path_info"); + if( (int)(query_string - req->url) > strlen(prefix) ) + { + lua_pushlstring(L, + &req->url[strlen(prefix)], + (int)(query_string - req->url) - strlen(prefix) + ); + + lua_setfield(L, -2, "path_info"); + } } - else + else if( strlen(req->url) > strlen(prefix) ) { - lua_pushstring(L, req->url); + lua_pushstring(L, &req->url[strlen(prefix)]); lua_setfield(L, -2, "path_info"); }