From 52feb7abacd0c1a3d4ab37ed981d191b181a2959 Mon Sep 17 00:00:00 2001 From: Marc Singer Date: Sat, 31 Mar 2012 16:17:09 -0700 Subject: [PATCH] Issue 167: Accept connections in subfolders o According to the poster, the desired feature it supporting arbitrary paths in the request URL s.t. proxying doesn't break SIAB. o Rewrote poster's patch to void pointer arithmetic. o Integrating comments from Markus. --- shellinabox/shellinaboxd.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/shellinabox/shellinaboxd.c b/shellinabox/shellinaboxd.c index f508c66..d0d787b 100644 --- a/shellinabox/shellinaboxd.c +++ b/shellinabox/shellinaboxd.c @@ -613,17 +613,16 @@ static int shellInABoxHttpHandler(HttpConnection *http, void *arg, const HashMap *headers = httpGetHeaders(http); const char *contentType = getFromHashMap(headers, "content-type"); - // Normalize the path info + // Normalize the path info, present the final path element const char *pathInfo = urlGetPathInfo(url); - while (*pathInfo == '/') { - pathInfo++; + int pathInfoLength = 0; + pathInfo = strrchr (pathInfo, '/'); + if (pathInfo) { + ++pathInfo; + } else { + pathInfo = ""; // Cheap way to get an empty string } - const char *endPathInfo; - for (endPathInfo = pathInfo; - *endPathInfo && *endPathInfo != '/'; - endPathInfo++) { - } - int pathInfoLength = endPathInfo - pathInfo; + pathInfoLength = strlen (pathInfo); if (!pathInfoLength || (pathInfoLength == 5 && !memcmp(pathInfo, "plain", 5)) ||