Skip to content

Commit

Permalink
[FIX]Fix deprecated warnings for preg_match() and mb_strtolower() in …
Browse files Browse the repository at this point in the history
…Webmail sieve filters
  • Loading branch information
Baraka24 committed Oct 14, 2024
1 parent a8dc883 commit 916a37b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions lib/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,19 @@ trait Hm_Handler_Validate {
* @return bool
*/
public function validate_method($session, $request) {
if (!in_array(mb_strtolower($request->method), ['get', 'post'], true)) {
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;
}
} else {
// Handle the case where method is null or invalid
if ($session->loaded) {
$session->destroy($request);
Hm_Debug::add(sprintf('LOGGED OUT: invalid method %s', $request->method));
Hm_Debug::add('LOGGED OUT: missing or invalid request method');
}
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/request.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ private function is_mobile() {
$this->mobile = true;
return;
}
if (array_key_exists('HTTP_USER_AGENT', $this->server)) {
if (array_key_exists('HTTP_USER_AGENT', $this->server) && !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;
}
Expand Down

0 comments on commit 916a37b

Please sign in to comment.