From 4ed645bac3b98a67f880ee47f6651b3a2d11eae8 Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Tue, 15 Jul 2025 13:13:11 +0900 Subject: [PATCH] Update email check with better domain name check (ASCII), logging class debug output update --- www/lib/CoreLibs/Check/Email.php | 12 ++++++++---- www/lib/CoreLibs/Logging/Logger/Level.php | 2 +- www/lib/CoreLibs/Logging/Logging.php | 7 ++++--- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/www/lib/CoreLibs/Check/Email.php b/www/lib/CoreLibs/Check/Email.php index 455a7d24..78938e92 100644 --- a/www/lib/CoreLibs/Check/Email.php +++ b/www/lib/CoreLibs/Check/Email.php @@ -10,12 +10,16 @@ class Email /** @var array */ private static array $email_regex_check = [ 0 => "^[A-Za-z0-9!#$%&'*+\-\/=?^_`{|}~][A-Za-z0-9!#$%:\(\)&'*+\-\/=?^_`{|}~\.]{0,63}@" - . "[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]{1,})*\.([a-zA-Z]{2,}){1}$", // MASTER + // . "[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]{1,})*\.([a-zA-Z]{2,}){1}$", // MASTER + // fixed pattern matching for domain + . "(?!-)[A-Za-z0-9-]{1,63}(? "@(.*)@(.*)", // double @ 2 => "^[A-Za-z0-9!#$%&'*+\-\/=?^_`{|}~][A-Za-z0-9!#$%:\(\)&'*+\-\/=?^_`{|}~\.]{0,63}@", // wrong part before @ - 3 => "@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]{1,})*\.([a-zA-Z]{2,}){1}$", // wrong part after @ - 4 => "@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]{1,})*\.", // wrong domain name part - 5 => "\.([a-zA-Z]{2,6}){1}$", // wrong top level part + // 3 => "@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]{1,})*\.([a-zA-Z]{2,}){1}$", // wrong part after @ + 3 => "@(?!-)[A-Za-z0-9-]{1,63}(? "@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]{1,})*\.", // wrong domain name part + 4 => "@@(?!-)[A-Za-z0-9-]{1,63}(? "\.[a-zA-Z]{2,6}$", // wrong top level part 6 => "@(.*)\.{2,}", // double .. in domain name part 7 => "@.*\.$" // ends with a dot, top level, domain missing ]; diff --git a/www/lib/CoreLibs/Logging/Logger/Level.php b/www/lib/CoreLibs/Logging/Logger/Level.php index ba497f70..dd59bfa6 100644 --- a/www/lib/CoreLibs/Logging/Logger/Level.php +++ b/www/lib/CoreLibs/Logging/Logger/Level.php @@ -112,7 +112,7 @@ enum Level: int } /** - * Returns true if the passed $level is higher or equal to $this + * Returns true if the passed $level is included in set level * * @param Level $level * @return bool diff --git a/www/lib/CoreLibs/Logging/Logging.php b/www/lib/CoreLibs/Logging/Logging.php index 0f9c498b..334ed6ca 100644 --- a/www/lib/CoreLibs/Logging/Logging.php +++ b/www/lib/CoreLibs/Logging/Logging.php @@ -1475,14 +1475,15 @@ class Logging Level::Error, Level::Critical, Level::Alert, Level::Emergency ] as $l ) { + print "Check: " . $this->log_level->getName() . " | " . $l->getName() . "
"; if ($this->log_level->isHigherThan($l)) { - print "L: " . $this->log_level->getName() . " > " . $l->getName() . "
"; + print "L(gt): " . $this->log_level->getName() . " > " . $l->getName() . "
"; } if ($this->log_level->includes($l)) { - print "L: " . $this->log_level->getName() . " <= " . $l->getName() . "
"; + print "L(le): " . $this->log_level->getName() . " <= " . $l->getName() . "
"; } if ($this->log_level->isLowerThan($l)) { - print "L: " . $this->log_level->getName() . " < " . $l->getName() . "
"; + print "L(lt): " . $this->log_level->getName() . " < " . $l->getName() . "
"; } echo "
"; }