Tweak fix from #8359

This fixes a regression introduced in that change that we didn't
previously have tests for. The issue fixed in #8359 was related to
PHP7.0, whereas PHP5 didn't have an issue. Now both versions will work
the same.
This commit is contained in:
mark_story 2016-03-02 12:30:48 -05:00
parent 63de5ca4ea
commit 3ad68db5eb
2 changed files with 8 additions and 1 deletions

View file

@ -448,7 +448,10 @@ class CakeRequest implements ArrayAccess {
if (!empty($ref) && !empty($base)) {
if ($local && strpos($ref, $base) === 0) {
$ref = substr($ref, strlen($base));
if (isset($ref[0]) && $ref[0] !== '/') {
if (empty($ref)) {
$ref = '/';
}
if ($ref[0] !== '/') {
$ref = '/' . $ref;
}
return $ref;

View file

@ -742,6 +742,10 @@ class CakeRequestTest extends CakeTestCase {
$result = $request->referer();
$this->assertSame($result, '/');
$_SERVER['HTTP_REFERER'] = Configure::read('App.fullBaseUrl') . '/';
$result = $request->referer(true);
$this->assertSame($result, '/');
$_SERVER['HTTP_REFERER'] = Configure::read('App.fullBaseUrl') . '/some/path';
$result = $request->referer(true);
$this->assertSame($result, '/some/path');