Index: trunk/extensions/Notificator/Notificator.body.php |
— | — | @@ -89,17 +89,33 @@ |
90 | 90 | |
91 | 91 | public static function receiverIsValid( $receiver ) { |
92 | 92 | // Returns true if the parameter is a valid e-mail address, false if not |
93 | | - $receiverIsValid = false; |
| 93 | + $receiverIsValid = true; |
94 | 94 | |
| 95 | + // There may be multiple e-mail addresses, divided by commas - which is valid |
| 96 | + // for us, but not for the validation functions we use below. So get the single |
| 97 | + // address into an array first, validate them one by one, and only if all are ok, |
| 98 | + // return true. |
| 99 | + $receiverArray = explode( ',', str_replace ( ', ', ',', $receiver ) ); |
| 100 | + |
| 101 | + // To make sure some joker doesn't copy in a large number of e-mail addresses |
| 102 | + // and spams them all, lets set a (admittedly arbitrary) limit of 10. |
| 103 | + if ( count( $receiverArray ) > 10 ) { |
| 104 | + return false; |
| 105 | + } |
| 106 | + |
| 107 | + if ( method_exists( 'Sanitizer', 'validateEmail' ) ) { |
95 | 108 | // User::isValidEmailAddr() has been moved to Sanitizer::validateEmail as of |
96 | 109 | // MediaWiki version 1.18 (I think). |
97 | | - if ( method_exists( 'Sanitizer', 'validateEmail' ) ) { |
98 | | - if ( Sanitizer::validateEmail( $receiver ) ) { |
99 | | - $receiverIsValid = true; |
| 110 | + foreach ( $receiverArray as $singleEmailAddress ) { |
| 111 | + if ( ! Sanitizer::validateEmail( $singleEmailAddress ) ) { |
| 112 | + $receiverIsValid = false; |
| 113 | + } |
100 | 114 | } |
101 | 115 | } else { |
102 | | - if ( User::isValidEmailAddr( $receiver ) ) { |
103 | | - $receiverIsValid = true; |
| 116 | + foreach ( $receiverArray as $singleEmailAddress ) { |
| 117 | + if ( ! User::isValidEmailAddr( $singleEmailAddress ) ) { |
| 118 | + $receiverIsValid = false; |
| 119 | + } |
104 | 120 | } |
105 | 121 | } |
106 | 122 | return $receiverIsValid; |