From 0fc8416d0fad52a8052ac4021f80c1d636863801 Mon Sep 17 00:00:00 2001 From: Baraka Kinywa Date: Mon, 14 Oct 2024 06:30:17 +0200 Subject: [PATCH] [FIX]Fix deprecated warnings for preg_match() and mb_strtolower() in Webmail sieve filters --- lib/module.php | 20 ++++++++++++++------ lib/request.php | 2 +- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/module.php b/lib/module.php index b5a45e8df0..0cdcbf0ae5 100644 --- a/lib/module.php +++ b/lib/module.php @@ -191,14 +191,22 @@ trait Hm_Handler_Validate { * @return bool */ public function validate_method($session, $request) { - if (!in_array(mb_strtolower($request->method), ['get', 'post'], true)) { - if ($session->loaded) { - $session->destroy($request); - Hm_Debug::add(sprintf('LOGGED OUT: invalid method %s', $request->method)); + if (!empty($request->method) && is_string($request->method)) { + if (!in_array(mb_strtolower($request->method), ['get', 'post'], true)) { + if ($session->loaded) { + $session->destroy($request); + Hm_Debug::add(sprintf('LOGGED OUT: invalid method %s', $request->method)); + } + return false; } - return false; + return true; } - return true; + // Handle the case where method is null or invalid + if ($session->loaded) { + $session->destroy($request); + Hm_Debug::add('LOGGED OUT: missing or invalid request method'); + } + return false; } /** diff --git a/lib/request.php b/lib/request.php index d76696592c..4f632759f4 100644 --- a/lib/request.php +++ b/lib/request.php @@ -175,7 +175,7 @@ private function is_mobile() { $this->mobile = true; return; } - if (array_key_exists('HTTP_USER_AGENT', $this->server)) { + if (!empty($this->server['HTTP_USER_AGENT'])) { if (preg_match("/(iphone|ipod|ipad|android|blackberry|webos|opera mini)/i", $this->server['HTTP_USER_AGENT'])) { $this->mobile = true; }