From af62240932bc54461702f96146a1e5feb77493f0 Mon Sep 17 00:00:00 2001 From: kristuff Date: Thu, 6 Oct 2022 00:14:00 +0200 Subject: [PATCH] Update email pattern in `cleanMessage()` method Update email pattern to handle local addresses without TLD and to allow using the caracter `@` in custom message. Close #4 --- lib/ApiHandler.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ApiHandler.php b/lib/ApiHandler.php index 9549260..a096706 100644 --- a/lib/ApiHandler.php +++ b/lib/ApiHandler.php @@ -469,8 +469,8 @@ class ApiHandler extends ApiBase } // If we're reporting spam, further munge any email addresses in the report - $emailPattern = "/[^@\s]*@[^@\s]*\.[^@\s]*/"; - $message = preg_replace($emailPattern, "*", $message); + $emailPattern = "/\b[A-Z0-9!#$%&'*`\/?^{|}~=+_.-]+@[A-Z0-9.-]+\b/i"; + $message = preg_replace($emailPattern, "*", $message); // Make sure message is less 1024 chars return substr($message, 0, 1024);