diff options
author | Mario <mario@mariovavti.com> | 2024-03-14 09:35:09 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2024-03-14 09:35:09 +0000 |
commit | 6bf61dfa6b585db01b607a79bd64ec9c583a9c10 (patch) | |
tree | 78698101aa58d918568dfc0020650fc337e8d3e0 /vendor/sabre/uri/lib | |
parent | 0e59cfb8390e4c6aee29ef73b53a4dc6b7fb581e (diff) | |
download | volse-hubzilla-6bf61dfa6b585db01b607a79bd64ec9c583a9c10.tar.gz volse-hubzilla-6bf61dfa6b585db01b607a79bd64ec9c583a9c10.tar.bz2 volse-hubzilla-6bf61dfa6b585db01b607a79bd64ec9c583a9c10.zip |
composer update and use the fixed streams php-jcs library until the floats issue will be fixed upstream. see here for reference https://codeberg.org/streams/streams/issues/151
Diffstat (limited to 'vendor/sabre/uri/lib')
-rw-r--r-- | vendor/sabre/uri/lib/Version.php | 2 | ||||
-rw-r--r-- | vendor/sabre/uri/lib/functions.php | 79 |
2 files changed, 49 insertions, 32 deletions
diff --git a/vendor/sabre/uri/lib/Version.php b/vendor/sabre/uri/lib/Version.php index e4f289e90..a30694f2c 100644 --- a/vendor/sabre/uri/lib/Version.php +++ b/vendor/sabre/uri/lib/Version.php @@ -16,5 +16,5 @@ class Version /** * Full version number. */ - public const VERSION = '2.3.2'; + public const VERSION = '2.3.3'; } diff --git a/vendor/sabre/uri/lib/functions.php b/vendor/sabre/uri/lib/functions.php index 64e64027f..01ef92d7e 100644 --- a/vendor/sabre/uri/lib/functions.php +++ b/vendor/sabre/uri/lib/functions.php @@ -26,15 +26,15 @@ function resolve(string $basePath, string $newPath): string // If the new path defines a scheme, it's absolute and we can just return // that. - if ($delta['scheme']) { + if (null !== $delta['scheme']) { return build($delta); } $base = parse($basePath); $pick = function ($part) use ($base, $delta) { - if ($delta[$part]) { + if (null !== $delta[$part]) { return $delta[$part]; - } elseif ($base[$part]) { + } elseif (null !== $base[$part]) { return $base[$part]; } @@ -47,7 +47,6 @@ function resolve(string $basePath, string $newPath): string $newParts['host'] = $pick('host'); $newParts['port'] = $pick('port'); - $path = ''; if (is_string($delta['path']) and strlen($delta['path']) > 0) { // If the path starts with a slash if ('/' === $delta['path'][0]) { @@ -62,7 +61,10 @@ function resolve(string $basePath, string $newPath): string $path .= '/'.$delta['path']; } } else { - $path = $base['path'] ?: '/'; + $path = $base['path'] ?? '/'; + if ('' === $path) { + $path = '/'; + } } // Removing .. and . $pathParts = explode('/', $path); @@ -85,13 +87,17 @@ function resolve(string $basePath, string $newPath): string // If the source url ended with a /, we want to preserve that. $newParts['path'] = 0 === strpos($path, '/') ? $path : '/'.$path; - if ($delta['query']) { + // From PHP 8, no "?" query at all causes 'query' to be null. + // An empty query "http://example.com/foo?" causes 'query' to be the empty string + if (null !== $delta['query'] && '' !== $delta['query']) { $newParts['query'] = $delta['query']; - } elseif (!empty($base['query']) && empty($delta['host']) && empty($delta['path'])) { + } elseif (isset($base['query']) && null === $delta['host'] && null === $delta['path']) { // Keep the old query if host and path didn't change $newParts['query'] = $base['query']; } - if ($delta['fragment']) { + // From PHP 8, no "#" fragment at all causes 'fragment' to be null. + // An empty fragment "http://example.com/foo#" causes 'fragment' to be the empty string + if (null !== $delta['fragment'] && '' !== $delta['fragment']) { $newParts['fragment'] = $delta['fragment']; } @@ -113,7 +119,7 @@ function normalize(string $uri): string { $parts = parse($uri); - if (!empty($parts['path'])) { + if (null !== $parts['path']) { $pathParts = explode('/', ltrim($parts['path'], '/')); $newPathParts = []; foreach ($pathParts as $pathPart) { @@ -134,14 +140,14 @@ function normalize(string $uri): string $parts['path'] = '/'.implode('/', $newPathParts); } - if ($parts['scheme']) { + if (null !== $parts['scheme']) { $parts['scheme'] = strtolower($parts['scheme']); $defaultPorts = [ 'http' => '80', 'https' => '443', ]; - if (!empty($parts['port']) && isset($defaultPorts[$parts['scheme']]) && $defaultPorts[$parts['scheme']] == $parts['port']) { + if (null !== $parts['port'] && isset($defaultPorts[$parts['scheme']]) && $defaultPorts[$parts['scheme']] == $parts['port']) { // Removing default ports. unset($parts['port']); } @@ -149,7 +155,7 @@ function normalize(string $uri): string switch ($parts['scheme']) { case 'http': case 'https': - if (empty($parts['path'])) { + if (null === $parts['path']) { // An empty path is equivalent to / in http. $parts['path'] = '/'; } @@ -157,7 +163,7 @@ function normalize(string $uri): string } } - if ($parts['host']) { + if (null !== $parts['host']) { $parts['host'] = strtolower($parts['host']); } @@ -201,7 +207,7 @@ function parse(string $uri): array } $result = parse_url($uri); - if (!$result) { + if (false === $result) { $result = _parse_fallback($uri); } @@ -238,32 +244,32 @@ function build(array $parts): string $uri = ''; $authority = ''; - if (!empty($parts['host'])) { + if (isset($parts['host'])) { $authority = $parts['host']; - if (!empty($parts['user'])) { + if (isset($parts['user'])) { $authority = $parts['user'].'@'.$authority; } - if (!empty($parts['port'])) { + if (isset($parts['port'])) { $authority = $authority.':'.$parts['port']; } } - if (!empty($parts['scheme'])) { + if (isset($parts['scheme'])) { // If there's a scheme, there's also a host. $uri = $parts['scheme'].':'; } - if ($authority || (!empty($parts['scheme']) && 'file' === $parts['scheme'])) { + if ('' !== $authority || (isset($parts['scheme']) && 'file' === $parts['scheme'])) { // No scheme, but there is a host. $uri .= '//'.$authority; } - if (!empty($parts['path'])) { + if (isset($parts['path'])) { $uri .= $parts['path']; } - if (!empty($parts['query'])) { + if (isset($parts['query'])) { $uri .= '?'.$parts['query']; } - if (!empty($parts['fragment'])) { + if (isset($parts['fragment'])) { $uri .= '#'.$parts['fragment']; } @@ -290,7 +296,7 @@ function build(array $parts): string function split(string $path): array { $matches = []; - if (preg_match('/^(?:(?:(.*)(?:\/+))?([^\/]+))(?:\/?)$/u', $path, $matches)) { + if (1 === preg_match('/^(?:(?:(.*)(?:\/+))?([^\/]+))(?:\/?)$/u', $path, $matches)) { return [$matches[1], $matches[2]]; } @@ -307,7 +313,7 @@ function split(string $path): array * This function is only called if the main parse method fails. It's pretty * crude and probably slow, so the original parse_url is usually preferred. * - * @return array<string, mixed> + * @return array{scheme: string|null, host: string|null, path: string|null, port: positive-int|null, user: string|null, query: string|null, fragment: string|null} * * @throws InvalidUriException */ @@ -340,10 +346,14 @@ function _parse_fallback(string $uri): array 'query' => null, ]; - if (preg_match('% ^([A-Za-z][A-Za-z0-9+-\.]+): %x', $uri, $matches)) { + if (1 === preg_match('% ^([A-Za-z][A-Za-z0-9+-\.]+): %x', $uri, $matches)) { $result['scheme'] = $matches[1]; // Take what's left. $uri = substr($uri, strlen($result['scheme']) + 1); + if (false === $uri) { + // There was nothing left. + $uri = ''; + } } // Taking off a fragment part @@ -358,7 +368,11 @@ function _parse_fallback(string $uri): array if ('///' === substr($uri, 0, 3)) { // The triple slash uris are a bit unusual, but we have special handling // for them. - $result['path'] = substr($uri, 2); + $path = substr($uri, 2); + if (false === $path) { + throw new \RuntimeException('The string cannot be false'); + } + $result['path'] = $path; $result['host'] = ''; } elseif ('//' === substr($uri, 0, 2)) { // Uris that have an authority part. @@ -369,22 +383,25 @@ function _parse_fallback(string $uri): array (?: : (?<port> [0-9]+))? (?<path> / .*)? $%x'; - if (!preg_match($regex, $uri, $matches)) { + if (1 !== preg_match($regex, $uri, $matches)) { throw new InvalidUriException('Invalid, or could not parse URI'); } - if ($matches['host']) { + if (isset($matches['host']) && '' !== $matches['host']) { $result['host'] = $matches['host']; } if (isset($matches['port'])) { - $result['port'] = (int) $matches['port']; + $port = (int) $matches['port']; + if ($port > 0) { + $result['port'] = $port; + } } if (isset($matches['path'])) { $result['path'] = $matches['path']; } - if ($matches['user']) { + if (isset($matches['user']) && '' !== $matches['user']) { $result['user'] = $matches['user']; } - if ($matches['pass']) { + if (isset($matches['pass']) && '' !== $matches['pass']) { $result['pass'] = $matches['pass']; } } else { |