private function Uri::filterPath in Zircon Profile 8
Same name in this branch
- 8 vendor/zendframework/zend-diactoros/src/Uri.php \Zend\Diactoros\Uri::filterPath()
- 8 vendor/guzzlehttp/psr7/src/Uri.php \GuzzleHttp\Psr7\Uri::filterPath()
Same name and namespace in other branches
- 8.0 vendor/zendframework/zend-diactoros/src/Uri.php \Zend\Diactoros\Uri::filterPath()
Filters the path of a URI to ensure it is properly encoded.
Parameters
string $path:
Return value
string
2 calls to Uri::filterPath()
- Uri::parseUri in vendor/
zendframework/ zend-diactoros/ src/ Uri.php - Parse a URI into its parts, and set the properties
- Uri::withPath in vendor/
zendframework/ zend-diactoros/ src/ Uri.php - Return an instance with the specified path.
File
- vendor/
zendframework/ zend-diactoros/ src/ Uri.php, line 551
Class
- Uri
- Implementation of Psr\Http\UriInterface.
Namespace
Zend\DiactorosCode
private function filterPath($path) {
$path = preg_replace_callback('/(?:[^' . self::CHAR_UNRESERVED . ':@&=\\+\\$,\\/;%]+|%(?![A-Fa-f0-9]{2}))/', [
$this,
'urlEncodeChar',
], $path);
if (empty($path)) {
// No path
return $path;
}
if ($path[0] !== '/') {
// Relative path
return $path;
}
// Ensure only one leading slash, to prevent XSS attempts.
return '/' . ltrim($path, '/');
}