File tree 1 file changed +2
-10
lines changed
1 file changed +2
-10
lines changed Original file line number Diff line number Diff line change @@ -171,16 +171,8 @@ private function checkCommentSimilarity(array $comments, Comment $comment): bool
171
171
public function checkForEmailAddress (Comment $ comment ): bool
172
172
{
173
173
$ commentText = $ comment ->getTextfree ();
174
- $ atPos = strpos ($ commentText , '@ ' );
175
- $ whiteSpaceBefore = strrpos (substr ($ commentText , 0 , $ atPos ), ' ' );
176
- $ whiteSpaceAfter = strpos ($ commentText , ' ' , $ atPos );
177
- if (false === $ whiteSpaceAfter ) {
178
- $ whiteSpaceAfter = strlen ($ commentText );
179
- }
180
- $ potentialEmailAddress =
181
- substr ($ commentText , $ whiteSpaceBefore + 1 , $ whiteSpaceAfter - $ whiteSpaceBefore - 1 );
182
- $ emailAddressFound = filter_var ($ potentialEmailAddress , FILTER_VALIDATE_EMAIL ) !== false ;
174
+ $ count = preg_match_all ("/[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/i " , $ commentText , $ matches );
183
175
184
- return $ emailAddressFound ;
176
+ return $ count > 0 ;
185
177
}
186
178
}
You can’t perform that action at this time.
0 commit comments