Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX]Fix deprecated warnings for preg_match() and mb_strtolower() in Webmail sieve filters #1281

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions lib/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,22 @@ trait Hm_Handler_Validate {
* @return bool
*/
public function validate_method($session, $request) {
Baraka24 marked this conversation as resolved.
Show resolved Hide resolved
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;
}

/**
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 (!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