mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge pull request #15181 from cakephp/fix-15163
Fix incorrect URL generation
This commit is contained in:
commit
1c27b82b49
2 changed files with 10 additions and 2 deletions
|
@ -256,7 +256,10 @@ class CakeRequest implements ArrayAccess {
|
||||||
if ($qPosition !== false && strpos($_SERVER['REQUEST_URI'], '://') > $qPosition) {
|
if ($qPosition !== false && strpos($_SERVER['REQUEST_URI'], '://') > $qPosition) {
|
||||||
$uri = $_SERVER['REQUEST_URI'];
|
$uri = $_SERVER['REQUEST_URI'];
|
||||||
} else {
|
} else {
|
||||||
$uri = substr($_SERVER['REQUEST_URI'], strlen(Configure::read('App.fullBaseUrl')));
|
$baseUrl = Configure::read('App.fullBaseUrl');
|
||||||
|
if (substr($_SERVER['REQUEST_URI'], 0, strlen($baseUrl)) === $baseUrl) {
|
||||||
|
$uri = substr($_SERVER['REQUEST_URI'], strlen($baseUrl));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} elseif (isset($_SERVER['PHP_SELF']) && isset($_SERVER['SCRIPT_NAME'])) {
|
} elseif (isset($_SERVER['PHP_SELF']) && isset($_SERVER['SCRIPT_NAME'])) {
|
||||||
$uri = str_replace($_SERVER['SCRIPT_NAME'], '', $_SERVER['PHP_SELF']);
|
$uri = str_replace($_SERVER['SCRIPT_NAME'], '', $_SERVER['PHP_SELF']);
|
||||||
|
|
|
@ -215,9 +215,14 @@ class CakeRequestTest extends CakeTestCase {
|
||||||
$request = new CakeRequest();
|
$request = new CakeRequest();
|
||||||
$this->assertEquals('some/path', $request->url);
|
$this->assertEquals('some/path', $request->url);
|
||||||
|
|
||||||
$_SERVER['REQUEST_URI'] = Configure::read('App.fullBaseUrl') . '/other/path?url=https://cakephp.org';
|
$base = Configure::read('App.fullBaseUrl');
|
||||||
|
$_SERVER['REQUEST_URI'] = $base . '/other/path?url=https://cakephp.org';
|
||||||
$request = new CakeRequest();
|
$request = new CakeRequest();
|
||||||
$this->assertEquals('other/path', $request->url);
|
$this->assertEquals('other/path', $request->url);
|
||||||
|
|
||||||
|
$_SERVER['REQUEST_URI'] = str_repeat('x', strlen($base) - 4) . '://?/other/path';
|
||||||
|
$request = new CakeRequest();
|
||||||
|
$this->assertEquals('', $request->url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue