Changeset 813
- Timestamp:
- Mar 29, 2024 10:43:24 PM (5 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Email.inc.php
r810 r813 113 113 // ...and something as simple as: 114 114 // x@x.com 115 $this->setParam(array('regex' => '/^(?:(?:"[^"]*?"\s*|[^,@]*)(<\s*)|(?:"[^"]*?"|[^,@]*)\s+|)' // Display name 116 . '((?:[^.<>\s@",\[\]]+[^<>\s@",\[\]])*[^.<>\s@",\[\]]+)' // Local-part 117 . '@' // @ 118 . '((?:(\[)|[a-z0-9]?)' // Domain, first char 119 . '(?(4)' // Domain conditional for if first domain char is [ 120 . '(?:[0-9]{1,3}\.){3}[0-9]{1,3}\]' // TRUE, matches IP address 121 . '|' 122 . '[.-]?(?:[a-z0-9]+[-.])*(?:[a-z0-9]+\.)+[a-z]{2,19}))' // FALSE, matches domain name 123 . '(?(1)' // Comment conditional for if initial < exists 124 . '(?:\s*>\s*|>\s+\([^,@]+\)\s*)' // TRUE, ensure ending > 125 . '|' 126 . '(?:|\s*|\s+\([^,@]+\)\s*))$/i' . $app->getParam('preg_u'))); // FALSE ensure there is no ending > 115 $this->setParam(['regex' => 116 '/^(?:(?:"[^"]*?"\s*|[^,@]*)(<\s*)|(?:"[^"]*?"|[^,@]*)\s+|)' // Display name 117 . '((?:[^.<>\s@",\[\]]+[^<>\s@",\[\]])*[^.<>\s@",\[\]]+)' // Local-part 118 . '@' // @ 119 . '((?:(\[)|[a-z0-9]?)' // Domain, first char 120 . '(?(4)' // Domain conditional for if first domain char is [ 121 . '(?:[0-9]{1,3}\.){3}[0-9]{1,3}\]' // TRUE, matches IP address 122 . '|' 123 . '(?:\.|-+)?(?:[a-z0-9]+(?:\.|-+)?)*(?:[a-z0-9]+\.)+[a-z]{2,19}))' // FALSE, matches domain name 124 . '(?(1)' // Comment conditional for if initial < exists 125 . '(?:\s*>\s*|>\s+\([^,@]+\)\s*)' // TRUE, ensure ending > 126 . '|' 127 . '(?:|\s*|\s+\([^,@]+\)\s*))$/i' . $app->getParam('preg_u') // FALSE ensure there is no ending > 128 ]); 127 129 128 130 if (isset($params)) { … … 527 529 /** 528 530 * Validates an email address based on the recommendations in RFC 3696. 529 * I s more loose than restrictive, to allow the many valid variants of531 * It's more loose than restrictive, to allow the many valid variants of 530 532 * email addresses while catching the most common mistakes. Checks an array too. 531 533 * http://www.faqs.org/rfcs/rfc822.html … … 556 558 if (preg_match($this->getParam('regex'), $email, $e_parts) && mb_strlen($e_parts[2]) < 64 && mb_strlen($e_parts[3]) < 255) { 557 559 return true; 558 } else {559 $app->logMsg(sprintf('Invalid email address: %s', $email), LOG_INFO, __FILE__, __LINE__); 560 return false;561 }560 } 561 562 $app->logMsg(sprintf('Invalid email address: %s', $email), LOG_INFO, __FILE__, __LINE__); 563 return false; 562 564 } 563 565 }
Note: See TracChangeset
for help on using the changeset viewer.