New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for #3318 #1377
Fix for #3318 #1377
Conversation
There should probably be a test case added for this as I'm sure it will break in the future without one. |
@@ -283,6 +283,9 @@ protected function _base() { | |||
if (!$baseUrl) { | |||
$base = dirname(env('PHP_SELF')); | |||
|
|||
if ($indexPos = strpos($base, '/webroot/index.php')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We generally avoid inline assignments as they are fickle and prone to error. As an example this will fail if $indexPos == 0.
Wouldn't "swallowing" index.php from the request uri cause problems with apps not using url rewriting? |
I was wondering about that, too. But honestly I assumed something that basic was covered by the test cases and they didn't seem to break... |
It is worth manually double checking as well. Breaking most IIS & cgi based setups would be bad. |
A really quick check on an IIS 7.5 using a vanilla cakephp worked for me... |
With and without url rewriting on IIS by the way... |
I would also check on apache without url rewriting with app in a subfolder of document root. |
Seems to work, too (after another really quick check) |
Fixes https://cakephp.lighthouseapp.com/projects/42648-cakephp/tickets/3318 It seems fixing this in the htaccess file(s) isn't going to work even though a url rewriting based solution was more clean. On the plus side this works for any web server. If a url is called with "index.php" in it then the CakeRequest swallows this part and fixes the path. Any linked url from the requested page will have a clean url. Thus after following one of these urls this problem is gone anyway. Some code docblock improvements to CakeRequestTest.php Added test case for fix Also now you can call just index.php even if you have url rewriting enabled
Hope the test is ok. Also now you can call just index.php even if you have url rewriting enabled. |
Thanks for the updates. I will give this a check tonight. |
Trim off webroot/index.php when determining base and url. Trimming off index.php from url and webroot/index.php from base url allows the correct values to be created when a path contains index.php in it. Fixes #3318
Fixes https://cakephp.lighthouseapp.com/projects/42648-cakephp/tickets/3318
It seems fixing this in the htaccess file(s) isn't going to work even though a url rewriting based solution was more clean. On the plus side this works for any web server.
If a url is called with "index.php" in it then the CakeRequest swallows this part and fixes the path. Any linked url from the requested page will have a clean url. Thus after following one of these urls this problem is gone anyway.