[BUGFIX] Fix return type of determineSiteScript 95/59395/5
authorHarald Atteneder <harald@urbantrout.io>
Thu, 10 Jan 2019 10:26:27 +0000 (10:26 +0000)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Fri, 1 Feb 2019 16:43:05 +0000 (17:43 +0100)
substr returns a boolean instead of an empty string. A typecast fixes
this problem (See http://php.net/manual/de/function.substr.php#90369)

Resolves: #87387
Releases: master, 9.5
Change-Id: I14aa49c18ae028dc27b94bfdbfc3dfb643c18746
Reviewed-on: https://review.typo3.org/59395
Tested-by: TYPO3com <noreply@typo3.com>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
Reviewed-by: Alexander Schnitzler <typo3@alexanderschnitzler.de>
Tested-by: Alexander Schnitzler <typo3@alexanderschnitzler.de>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/core/Classes/Http/NormalizedParams.php
typo3/sysext/core/Tests/Unit/Http/NormalizedParamsTest.php

index 6190c6d..be36a69 100644 (file)
@@ -805,6 +805,6 @@ class NormalizedParams
      */
     protected static function determineSiteScript(string $requestUrl, string $siteUrl): string
     {
-        return substr($requestUrl, strlen($siteUrl));
+        return (string)substr($requestUrl, strlen($siteUrl));
     }
 }
index 251d943..1de5384 100644 (file)
@@ -964,6 +964,16 @@ class NormalizedParamsTest extends UnitTestCase
                 '/var/www/myInstance/Web',
                 'typo3/index.php?id=42&foo=bar'
             ],
+            'redirected to a sub directory' => [
+                'serverParams' => [
+                    'REQUEST_URI' => '/',
+                    'SCRIPT_NAME' => '/public/',
+                    'HTTP_HOST' => 'www.domain.com',
+                ],
+                'pathThisScript' => '/var/www/html/public/index.php',
+                'pathSite' => '/var/www/html/html/public',
+                'expected' => ''
+            ],
         ];
     }