Index: trunk/extensions/Notificator/Notificator.body.php |
— | — | @@ -21,7 +21,7 @@ |
22 | 22 | } |
23 | 23 | |
24 | 24 | // Check whether the parameter is a valid e-mail address or not |
25 | | - if($receiver && Notificator::checkEmailAddress($receiver)) { |
| 25 | + if($receiver && Sanitizer::validateEmail($receiver)) { |
26 | 26 | // Valid e-mail address available, so just show a button |
27 | 27 | $output = '<form action="' . $wgScript . '/Special:Notificator" method="post" enctype="multipart/form-data"> |
28 | 28 | <input type="hidden" name="pageId" value="' . $wgTitle->getArticleID() . '" /> |
— | — | @@ -58,56 +58,6 @@ |
59 | 59 | return $ret; |
60 | 60 | } |
61 | 61 | |
62 | | -public static function checkEmailAddress($string) { |
63 | | -// from http://www.linuxjournal.com/article/9585 |
64 | | - $isValid = true; |
65 | | - $atIndex = strrpos($string, "@"); |
66 | | - if (is_bool($atIndex) && !$atIndex) { |
67 | | - $isValid = false; |
68 | | - } else { |
69 | | - $domain = substr($string, $atIndex+1); |
70 | | - $local = substr($string, 0, $atIndex); |
71 | | - $localLen = strlen($local); |
72 | | - $domainLen = strlen($domain); |
73 | | - if ($localLen < 1 || $localLen > 64) { |
74 | | - // local part length exceeded |
75 | | - $isValid = false; |
76 | | - } |
77 | | - else if ($domainLen < 1 || $domainLen > 255) { |
78 | | - // domain part length exceeded |
79 | | - $isValid = false; |
80 | | - } |
81 | | - else if ($local[0] == '.' || $local[$localLen-1] == '.') { |
82 | | - // local part starts or ends with '.' |
83 | | - $isValid = false; |
84 | | - } |
85 | | - else if (preg_match('/\\.\\./', $local)) { |
86 | | - // local part has two consecutive dots |
87 | | - $isValid = false; |
88 | | - } |
89 | | - else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain)) { |
90 | | - // character not valid in domain part |
91 | | - $isValid = false; |
92 | | - } |
93 | | - else if (preg_match('/\\.\\./', $domain)) { |
94 | | - // domain part has two consecutive dots |
95 | | - $isValid = false; |
96 | | - } |
97 | | - else if (!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', str_replace("\\\\","",$local))) { |
98 | | - // character not valid in local part unless |
99 | | - // local part is quoted |
100 | | - if (!preg_match('/^"(\\\\"|[^"])+"$/', str_replace("\\\\","",$local))) { |
101 | | - $isValid = false; |
102 | | - } |
103 | | - } |
104 | | - if ($isValid && !(checkdnsrr($domain,"MX") || checkdnsrr($domain,"A"))) { |
105 | | - // domain not found in DNS |
106 | | - $isValid = false; |
107 | | - } |
108 | | - } |
109 | | - return $isValid; |
110 | | -} |
111 | | - |
112 | 62 | public static function getLastNotifiedRevId($pageId, $revId, $receiver) { |
113 | 63 | // Returns -1 if any parameter is missing |
114 | 64 | // Returns -2 if the database revId is the same as the given revId (= notified already) |
Index: trunk/extensions/Notificator/SpecialNotificator.php |
— | — | @@ -28,7 +28,7 @@ |
29 | 29 | $pageTitle = $titleObj->getFullText(); |
30 | 30 | $linkToPage = $titleObj->getFullURL(); |
31 | 31 | |
32 | | - if(! Notificator::checkEmailAddress($receiver)) { |
| 32 | + if(! Sanitizer::validateEmail($receiver)) { |
33 | 33 | $output = '<span class="error">' . wfMsg('e-mail-address-invalid') . ' ' . wfMsg('notification-not-sent') . '</span>'; |
34 | 34 | $output .= Notificator::getReturnToText($linkToPage, $pageTitle); |
35 | 35 | $wgOut->addHTML($output); |