Project

General

Profile

Bug #2861

Regression: PHP URLs return 404 from lighttpd when they contain PATH_INFO ending in a trailing slash.

Added by ReimuHakurei 7 months ago. Updated 7 months ago.

Status:
Fixed
Priority:
Normal
Assignee:
-
Category:
core
Target version:
Start date:
2018-02-01
Due date:
% Done:

100%

Estimated time:
Missing in 1.5.x:

Description

Sometime between 1.4.48 and latest Git master, this bug has been introduced.

http://someserver/index.php/whatever <- works, gets passed along to PHP properly
http://someserver/index.php/whatever/ <- lighttpd returns 404, doesn't get passed along to PHP.

Associated revisions

Revision 6a6d3269 (diff)
Added by gstrauss 7 months ago

[core] fix path-info calculation in git master (fixes #2861)

(thx ReimuHakurei)

x-ref:
"Regression: PHP URLs return 404 from lighttpd when they contain PATH_INFO ending in a trailing slash."
https://redmine.lighttpd.net/issues/2861

History

#1

Updated by gstrauss 7 months ago

  • Category set to core
  • Target version changed from 1.4.x to 1.4.49

Thanks for reporting this. Bug would probably be in commit ec9e6abc I will look further later today.

#2

Updated by gstrauss 7 months ago

Looks like 'pathinfo' variable was incorrectly overloaded in the code and I need to add back 'found' flag.

#3

Updated by gstrauss 7 months ago

--- a/src/response.c
+++ b/src/response.c
@@ -184,12 +184,14 @@ static handler_t http_response_physical_path_check(server *srv, connection *con)
                        if ('/' != *pathinfo) pathinfo = NULL;
                }

-               for (; pathinfo; pathinfo = strchr(pathinfo+1, '/')) {
-                       handler_t rc;
-                       *pathinfo = '\0';
-                       rc = stat_cache_get_entry(srv, con, con->physical.path, &sce);
-                       *pathinfo = '/';
-                       if (HANDLER_ERROR == rc) { pathinfo = NULL; break; }
+               for (char *pprev = pathinfo; pathinfo; pprev = pathinfo, pathinfo = strchr(pathinfo+1, '/')) {
+                       stat_cache_entry *nsce = NULL;
+                       buffer_copy_string_len(srv->tmp_buf, con->physical.path->ptr, pathinfo - con->physical.path->ptr);
+                       if (HANDLER_ERROR == stat_cache_get_entry(srv, con, srv->tmp_buf, &nsce)) {
+                               pathinfo = pathinfo != pprev ? pprev : NULL;
+                               break;
+                       }
+                       sce = nsce;
                        if (!S_ISDIR(sce->st.st_mode)) break;
                }

#4

Updated by gstrauss 7 months ago

  • Status changed from New to Patch Pending
#5

Updated by gstrauss 7 months ago

  • Status changed from Patch Pending to Fixed
  • % Done changed from 0 to 100

Also available in: Atom