From cc9327642225bb0df962636a5c344afc01f57a54 Mon Sep 17 00:00:00 2001 From: Jamie Burchell Date: Tue, 8 Mar 2022 14:25:19 +0000 Subject: [PATCH] Fix preg_match search on NULL Fixes https://github.com/thephpleague/omnipay-sagepay/issues/177#issuecomment-1061603591 --- src/Message/DirectAuthorizeRequest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Message/DirectAuthorizeRequest.php b/src/Message/DirectAuthorizeRequest.php index 80cd04b..5928940 100644 --- a/src/Message/DirectAuthorizeRequest.php +++ b/src/Message/DirectAuthorizeRequest.php @@ -135,7 +135,7 @@ public function getClientIp() $ip = parent::getClientIp(); // OmniPay core could do with a helper for this. - if (! preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $ip)) { + if (! is_null($ip) && ! preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $ip)) { $ip = null; }