Commit 906873a6 authored by Jochen Roth's avatar Jochen Roth Committed by Benni Mack
Browse files

[BUGFIX] Cast $siteUrl to string

In case substr returns false $siteUrl
is now casted to string and covered
by an additional unit test.

Resolves: #94624
Releases: master
Change-Id: Id778319104d107c329a2ee8f947571a87e3c401d
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/70059

Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: Oliver Klee's avatarOliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent 4ab93f35
......@@ -824,7 +824,7 @@ class NormalizedParams
protected static function determineSiteUrl(string $requestDir, string $pathThisScript, string $pathSite): string
{
$pathThisScriptDir = substr(dirname($pathThisScript), strlen($pathSite)) . '/';
$siteUrl = substr($requestDir, 0, -strlen($pathThisScriptDir));
$siteUrl = (string)substr($requestDir, 0, -strlen($pathThisScriptDir));
return rtrim($siteUrl, '/') . '/';
}
......
......@@ -945,6 +945,19 @@ class NormalizedParamsTest extends UnitTestCase
self::assertSame($expected, $serverRequestParameters->getSiteUrl());
}
/**
* @test
*/
public function getSiteUrlReturnsExpectedUrlForCliCommand()
{
$serverParams = [];
$pathThisScript = '/var/www/html/typo3temp/var/tests/acceptance/typo3/sysext/core/bin/typo3';
$pathSite = '/var/www/html/typo3temp/var/tests/acceptance/';
$expected = '/';
$serverRequestParameters = new NormalizedParams($serverParams, [], $pathThisScript, $pathSite);
self::assertSame($expected, $serverRequestParameters->getSiteUrl());
}
/**
* @return array[]
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment