diff options
author | Joas Schilling <coding@schilljs.com> | 2024-02-13 16:48:16 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2024-02-13 16:51:13 +0100 |
commit | c4684089a8542e71c8073c4bbf516ee5c0f6e0b6 (patch) | |
tree | 687d98615bae64085ef76c488e2210ab7f942dee /lib/private/AppFramework | |
parent | 9ed3ab7d87767d8979fe9f40818a841a146c08de (diff) | |
download | nextcloud-server-c4684089a8542e71c8073c4bbf516ee5c0f6e0b6.tar.gz nextcloud-server-c4684089a8542e71c8073c4bbf516ee5c0f6e0b6.zip |
fix(request): Fix regex handling and coding-style
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/AppFramework')
-rw-r--r-- | lib/private/AppFramework/Http/Request.php | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/private/AppFramework/Http/Request.php b/lib/private/AppFramework/Http/Request.php index fc72a3f4525..854585a41d6 100644 --- a/lib/private/AppFramework/Http/Request.php +++ b/lib/private/AppFramework/Http/Request.php @@ -608,13 +608,12 @@ class Request implements \ArrayAccess, \Countable, IRequest { foreach (array_reverse(explode(',', $this->server[$header])) as $IP) { $IP = trim($IP); $colons = substr_count($IP, ':'); - if($colons > 1) { + if ($colons > 1) { // Extract IP from string with brackets and optional port - if(1 === preg_match('`^\[(.+?)\](?::\d+)?$`', $IP, $matches) && count($matches) === 1) { - $IP = $matches[0]; + if (preg_match('/^\[(.+?)\](?::\d+)?$/', $IP, $matches) && isset($matches[1])) { + $IP = $matches[1]; } - } - elseif($colons === 1) { + } elseif ($colons === 1) { // IPv4 with port $IP = substr($IP, 0, strpos($IP, ':')); } |