From eda0430c939b507e98340f4e04e2f08e71264654 Mon Sep 17 00:00:00 2001 From: Oleg Kasyanov Date: Sat, 20 Jan 2024 12:11:47 +0400 Subject: [PATCH] Improved comparison of the condition --- src/Http/IpAndUserAgentMiddleware.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Http/IpAndUserAgentMiddleware.php b/src/Http/IpAndUserAgentMiddleware.php index 6242984..6514149 100644 --- a/src/Http/IpAndUserAgentMiddleware.php +++ b/src/Http/IpAndUserAgentMiddleware.php @@ -61,7 +61,11 @@ public function determineIpViaProxyAddress(ServerRequestInterface $request): ?st foreach ($this->headersToInspect as $header) { if ( $request->hasHeader($header) - && preg_match_all('#\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}#s', $request->getHeaderLine($header), $vars) + && preg_match_all( + '#\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}#s', + $request->getHeaderLine($header), + $vars + ) !== false && null !== ($ip = $this->extractIp($request, $vars)) ) { return $ip;