src/Uri.php
/**
     * Filters the path of a URI to ensure it is properly encoded.
     */
Filters the path of a URI to ensure it is properly encoded.
Filters the path of a URI to ensure it is properly encoded .
private function filterPath(string $path) : string
    {
        $path = $this->filterInvalidUtf8($path);
        $path = preg_replace_callback(
            '/(?:[^' . self::CHAR_UNRESERVED . ')(:@&=\+\$,\/;%]+|%(?![A-Fa-f0-9]{2}))/u',
            [$this, 'urlEncodeChar'],
            $path
        );
        if ('' === $path) {
            return $path;
        }
        if ($path[0] !== '/') {
            return $path;
        }
        return '/' . ltrim($path, '/');
    }
private function filterPath ( string $ path ) : string { $ path = $ this -> filterInvalidUtf8 ( $ path ) ; $ path = preg_replace_callback ( '/(?:[^' . self :: CHAR_UNRESERVED . ')(:@&=\+\$,\/;%]+|%(?![A-Fa-f0-9]{2}))/u' , [ $ this , 'urlEncodeChar' ] , $ path ) ; if ( '' === $ path ) { return $ path ; } if ( $ path [ 0 ] !== '/' ) { return $ path ; } return '/' . ltrim ( $ path , '/' ) ; }
Filters the path of a URI to ensure it is properly encoded.
Filters the path of a URI to ensure it is properly encoded .
// No path // Relative path // Ensure only one leading slash, to prevent XSS attempts.