From 8034899092e4a376efeaa047e0db20e1c1b0441c Mon Sep 17 00:00:00 2001 From: Lennart Sauerbeck Date: Thu, 31 Aug 2017 14:36:07 +0200 Subject: [PATCH] HttpServer: Remove all leading slashes of served files Previously only one leading slash was removed. This would lead to problems with the following Qt calls if there was more than one slash in the URL. The path would not be relative to `m_ServeFilesDirectory` but would be treated as absolute, leading to an error message because `HttpServer` does not allow reading outside of `m_ServeFilesDirectory` (and rightfully so). Signed-off-by: Lennart Sauerbeck --- src/httpserver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/httpserver.cpp b/src/httpserver.cpp index a7a9e139..8bc7611e 100644 --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -854,7 +854,7 @@ bool HttpServer::searchAndServeFile(HttpData& data) const // TODO: WOULD BE NICE TO CACHE STRING CONSTRUCTION. QString urlPath = data.getRequest().getUrl().getPath(); - if(urlPath.startsWith('/')) + while(urlPath.startsWith('/')) { urlPath = urlPath.mid(1); }