Skip to content

Commit ead327f

Browse files
author
Cyrille TOULET
committed
Fix an "strpos(): Empty needle" warning
Signed-off-by: Cyrille TOULET <[email protected]>
1 parent dabdbe4 commit ead327f

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

system/core/URI.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,14 +205,17 @@ protected function _parse_request_uri()
205205
$query = isset($uri['query']) ? $uri['query'] : '';
206206
$uri = isset($uri['path']) ? $uri['path'] : '';
207207

208-
if (!empty($_SERVER['SCRIPT_NAME']) && strpos($uri, $_SERVER['SCRIPT_NAME']) === 0)
209-
{
210-
$uri = (string) substr($uri, strlen($_SERVER['SCRIPT_NAME']));
211-
}
212-
elseif (!empty($_SERVER['SCRIPT_NAME']) && strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0)
213-
{
214-
$uri = (string) substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME'])));
215-
}
208+
if (isset($_SERVER['SCRIPT_NAME'][0]))
209+
{
210+
if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0)
211+
{
212+
$uri = (string) substr($uri, strlen($_SERVER['SCRIPT_NAME']));
213+
}
214+
elseif (strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0)
215+
{
216+
$uri = (string) substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME'])));
217+
}
218+
}
216219

217220
// This section ensures that even on servers that require the URI to be in the query string (Nginx) a correct
218221
// URI is found, and also fixes the QUERY_STRING server var and $_GET array.

0 commit comments

Comments
 (0)