From b9c290b5480a958eabeef66d5e9af799f77e4566 Mon Sep 17 00:00:00 2001 From: David King Date: Tue, 20 Nov 2012 16:13:29 -0500 Subject: [PATCH] [ticket/11215] Correct for different URL but same path info When Symfony Request calculates path info, both of the following URLs give "/" as the path info: ./app.php and ./app.php/ This commit ensures that the proper correction is made. PHPBB3-11215 --- phpBB/includes/functions.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 213f178694..331eaf742e 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5743,7 +5743,16 @@ function phpbb_get_web_root_path(Request $symfony_request) } $path_info = $symfony_request->getPathInfo(); - if ($path_info == '/') + + // When no path is given (i.e. REQUEST_URI = "./app.php") path info from + // the Symfony Request object is "/". However, that is the same as when + // the REQUEST_URI is "./app.php/". So we want to correct the path when + // we have a trailing slash in the REQUEST_URI, but not when we don't. + $request_uri = $symfony_request->server->get('REQUEST_URI'); + $trailing_slash = substr($request_uri, -1) === '/'; + + // If pathinfo is / and we do not have a trailing slash in the REQUEST_URI + if (!$trailing_slash && '/' === $path_info) { $path = ''; return $path;