Allow internal TLDs and special characters in e-mail addresses

This commit is contained in:
Maurus Decimus
2026-05-20 06:51:34 +02:00
parent 83a1543483
commit e9f9d81866
2 changed files with 13 additions and 5 deletions

View File

@@ -213,10 +213,14 @@ pub fn sanitize_email(email: &str) -> Option<String> {
for ch in chars.by_ref() {
match ch {
'.' | '+' | '-' | '_' => {
if !last_ch.is_alphanumeric() {
'.' => {
if last_ch == NIL_CHAR || last_ch == '.' {
return None;
}
result.push('.');
}
'!' | '#' | '$' | '%' | '&' | '\'' | '*' | '+' | '-' | '/' | '=' | '?' | '^' | '_'
| '`' | '{' | '|' | '}' | '~' => {
result.push(ch);
}
' ' | '\x09'..='\x0d' => continue,
@@ -288,10 +292,14 @@ pub fn sanitize_email_local(local: &str) -> Option<String> {
for ch in local.chars() {
match ch {
'.' | '+' | '-' | '_' => {
if !last_ch.is_alphanumeric() {
'.' => {
if last_ch == NIL_CHAR || last_ch == '.' {
return None;
}
result.push('.');
}
'!' | '#' | '$' | '%' | '&' | '\'' | '*' | '+' | '-' | '/' | '=' | '?' | '^' | '_'
| '`' | '{' | '|' | '}' | '~' => {
result.push(ch);
}
' ' | '\x09'..='\x0d' => continue,