From 0f18174879e121e5c5a64de0e3cb88a9c78e2b37 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sat, 20 Mar 2010 13:45:50 +0000 Subject: uhttpd: - rework url parsing and path resolving - handle more cgi quirks - change request dispatching - clean up cflags --- contrib/package/uhttpd/src/uhttpd-lua.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'contrib/package/uhttpd/src/uhttpd-lua.c') 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"); } -- cgit v1.2.3