Bug #1345
closedWrong PATH_INFO and SCRIPT_NAME when Request-URI have trailing slash
Description
When you make request like this: "http://hostname/script.php/somestring/" then PATH_INFO is set to "/" (in response.c con->request.pathinfo is set to "/somestring") and SCRIPT_NAME is set to "/script.php/".
But when you request script in userdir (http://hostname/~user/script.php/somestring/) then PATH_INFO and SCRIPT_NAME is set to proper values.
In response.c after make "physical filename" we strip trailing slash from physical.path (if it exist) but it necessary only on win32.
In first case in response.c no transform is made to physical.path (response.c.480: (trace) -- logical -> physical), in second there is transform to real path and after that transform trailing slash is back to physical.path.
And after that we search for pathinfo. But in first case it's shortest that this in request (no "/") and we remove this shortest pathinfo from uri.path and we have wrong pathinfo and path to script.
Simple solution for unix/linux is to make conditional build of code that striping trailing slash (make it under win32 only).
Some traces:
Case 1:
response.c.226: (trace) -- splitting Request-URI response.c.227: (trace) Request-URI : /info.php/werer/wwewe/ response.c.228: (trace) URI-scheme : http response.c.229: (trace) URI-authority: ads.devel.int.apollo.pl response.c.230: (trace) URI-path : /info.php/werer/wwewe/ response.c.231: (trace) URI-query : (null) response.c.285: (trace) -- sanitizing URI response.c.286: (trace) URI-path : /info.php/werer/wwewe/ mod_access.c.138: (trace) -- handling file in mod_access response.c.402: (trace) -- before doc_root response.c.403: (trace) Doc-Root : /home/users/pepe/www/ads.apollo.pl/ response.c.404: (trace) Rel-Path : /info.php/werer/wwewe/ response.c.405: (trace) Path : /home/users/pepe/www/ads.apollo.pl/info.php response.c.458: (trace) -- after doc_root response.c.459: (trace) Doc-Root : /home/users/pepe/www/ads.apollo.pl/ response.c.460: (trace) Rel-Path : /info.php/werer/wwewe/ response.c.461: (trace) Path : /home/users/pepe/www/ads.apollo.pl/info.php/werer/wwewe response.c.480: (trace) -- logical -> physical response.c.481: (trace) Doc-Root : /home/users/pepe/www/ads.apollo.pl/ response.c.482: (trace) Rel-Path : /info.php/werer/wwewe/ response.c.483: (trace) Path : /home/users/pepe/www/ads.apollo.pl/info.php/werer/wwewe response.c.501: (trace) -- handling physical path response.c.502: (trace) Path : /home/users/pepe/www/ads.apollo.pl/info.php/werer/wwewe response.c.649: (trace) -- after pathinfo check response.c.650: (trace) Path : /home/users/pepe/www/ads.apollo.pl/info.php response.c.651: (trace) URI : /info.php/ response.c.652: (trace) Pathinfo : /werer/wwewe response.c.663: (trace) -- handling subrequest response.c.664: (trace) Path : /home/users/pepe/www/ads.apollo.pl/info.php
Case 2:
response.c.226: (trace) -- splitting Request-URI response.c.227: (trace) Request-URI : /~pepe/php/info.php/werer/wwewe/ response.c.228: (trace) URI-scheme : http response.c.229: (trace) URI-authority: ads.devel.int.apollo.pl response.c.230: (trace) URI-path : /~pepe/php/info.php/werer/wwewe/ response.c.231: (trace) URI-query : (null) response.c.285: (trace) -- sanitizing URI response.c.286: (trace) URI-path : /~pepe/php/info.php/werer/wwewe/ mod_access.c.138: (trace) -- handling file in mod_access response.c.402: (trace) -- before doc_root response.c.403: (trace) Doc-Root : /home/users/pepe/www/ads.apollo.pl/ response.c.404: (trace) Rel-Path : /~pepe/php/info.php/werer/wwewe/ response.c.405: (trace) Path : /home/users/pepe/www/ads.apollo.pl/info.php response.c.458: (trace) -- after doc_root response.c.459: (trace) Doc-Root : /home/users/pepe/www/ads.apollo.pl/ response.c.460: (trace) Rel-Path : /~pepe/php/info.php/werer/wwewe/ response.c.461: (trace) Path : /home/users/pepe/www/ads.apollo.pl/~pepe/php/info.php/werer/wwewe response.c.480: (trace) -- logical -> physical response.c.481: (trace) Doc-Root : /home/users/pepe/www/ads.apollo.pl/ response.c.482: (trace) Rel-Path : /~pepe/php/info.php/werer/wwewe/ response.c.483: (trace) Path : /home/users/pepe/public_html/php/info.php/werer/wwewe/ response.c.501: (trace) -- handling physical path response.c.502: (trace) Path : /home/users/pepe/public_html/php/info.php/werer/wwewe/ response.c.501: (trace) -- handling physical path response.c.502: (trace) Path : /home/users/pepe/public_html/php/info.php/werer/wwewe/ response.c.649: (trace) -- after pathinfo check response.c.650: (trace) Path : /home/users/pepe/public_html/php/info.php response.c.651: (trace) URI : /~pepe/php/info.php response.c.652: (trace) Pathinfo : /werer/wwewe/ response.c.663: (trace) -- handling subrequest response.c.664: (trace) Path : /home/users/pepe/public_html/php/info.php
PS. Sorry for my bad english.
-- pepe
Updated by gstrauss over 8 years ago
- Related to Bug #1087: Regression: broken physical.path handling in function handle_get_backend. added
Updated by gstrauss over 8 years ago
- Description updated (diff)
- Assignee deleted (
jan) - Priority changed from High to Normal
Updated by gstrauss over 8 years ago
- Missing in 1.5.x set to Yes
FYI: in lighttpd 1.4.x, stripping trailing slash in response.c is done only for Win32 and Cygwin
Also available in: Atom