From 9cfc080ab725ce4695c21514fba336c2c2c5023d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Fri, 30 Aug 2013 15:02:44 +0000 Subject: [PATCH] [core] allow files to be used as document-root (fixes #2475) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Stefan Bühler git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2900 152afb58-edef-0310-8abb-c4023f1b3aa9 --- NEWS | 1 + src/mod_alias.c | 3 ++- src/response.c | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index df6652fd..ed7c03a5 100644 --- a/NEWS +++ b/NEWS @@ -32,6 +32,7 @@ NEWS * [core] check whether server.chroot exists * [mod_simple_vhost] fix cache; skip module if simple-vhost.server-root is empty (thx rm for reporting) * [mod_accesslog] add accesslog.syslog-level option (fixes #2480) + * [core] allow files to be used as document-root (fixes #2475) - 1.4.32 - 2012-11-21 * Code cleanup with clang/sparse (fixes #2437, thx kibi) diff --git a/src/mod_alias.c b/src/mod_alias.c index 5b7b5107..0bac56b1 100644 --- a/src/mod_alias.c +++ b/src/mod_alias.c @@ -156,7 +156,8 @@ PHYSICALPATH_FUNC(mod_alias_physical_handler) { mod_alias_patch_connection(srv, con, p); /* not to include the tailing slash */ - basedir_len = (con->physical.basedir->used - 1) - 1; + basedir_len = (con->physical.basedir->used - 1); + if ('/' == con->physical.basedir->ptr[basedir_len-1]) --basedir_len; uri_len = con->physical.path->used - 1 - basedir_len; uri_ptr = con->physical.path->ptr + basedir_len; diff --git a/src/response.c b/src/response.c index 0875efd8..1198d491 100644 --- a/src/response.c +++ b/src/response.c @@ -517,8 +517,8 @@ handler_t http_response_prepare(server *srv, connection *con) { */ buffer_copy_string_buffer(con->physical.path, con->physical.doc_root); - BUFFER_APPEND_SLASH(con->physical.path); buffer_copy_string_buffer(con->physical.basedir, con->physical.path); + BUFFER_APPEND_SLASH(con->physical.path); if (con->physical.rel_path->used && con->physical.rel_path->ptr[0] == '/') { buffer_append_string_len(con->physical.path, con->physical.rel_path->ptr + 1, con->physical.rel_path->used - 2);