Index: trunk/extensions/ArticleComments/ArticleComments.php |
— | — | @@ -316,7 +316,7 @@ |
317 | 317 | if ( !$commenterName ) $messages[] = wfMsgForContent( |
318 | 318 | 'article-comments-required-field', wfMsgForContent( 'article-comments-name-string' ) ); |
319 | 319 | |
320 | | - if ( !preg_match( "/^(" . wfUrlProtocols() . ')' . Parser::EXT_LINK_URL_CLASS . '+$/', $commenterURL ) ) |
| 320 | + if ( ( $commenterURL != '' ) && !preg_match( "/^(" . wfUrlProtocols() . ')' . Parser::EXT_LINK_URL_CLASS . '+$/', $commenterURL ) ) |
321 | 321 | $messages[] = wfMsgForContent( |
322 | 322 | 'article-comments-invalid-field', wfMsgForContent( 'article-comments-url-string' ), $commenterURL ); |
323 | 323 | |
— | — | @@ -450,17 +450,23 @@ |
451 | 451 | * @param Boolean $isspam Whether the comment is spam (passed by reference) |
452 | 452 | * @return Boolean Always true to indicate other hooking methods may continue to check for spam. |
453 | 453 | */ |
454 | | -function defaultArticleCommentSpamCheck( $comment, $commenterName, $commenterURL, $isspam ) { |
| 454 | +function defaultArticleCommentSpamCheck( $comment, $commenterName, $commenterURL, &$isspam ) { |
455 | 455 | |
456 | | - # Short-circuit if spam has already been determined |
457 | | - if ( $isspam ) return true; |
| 456 | + if ( $isspam ) { |
| 457 | + # This module only marks comments as spam (other modules may unspam) |
| 458 | + return true; |
| 459 | + } |
| 460 | + |
458 | 461 | $fields = array( $comment, $commenterName, $commenterURL ); |
459 | 462 | |
460 | 463 | # Run everything through $wgSpamRegex if it has been specified |
461 | 464 | global $wgSpamRegex; |
462 | 465 | if ( $wgSpamRegex ) { |
463 | 466 | foreach ( $fields as $field ) { |
464 | | - if ( preg_match( $wgSpamRegex, $field ) ) return $isspam = true; |
| 467 | + if ( preg_match( $wgSpamRegex, $field ) ) { |
| 468 | + $isspam = true; |
| 469 | + return true; |
| 470 | + } |
465 | 471 | } |
466 | 472 | } |
467 | 473 | |
— | — | @@ -470,21 +476,33 @@ |
471 | 477 | '%<a\\s+[^>]*href\\s*=\\s*[\'"]?\\s*(https?|ftp)://%smi' |
472 | 478 | ); |
473 | 479 | foreach ( $spampatterns as $sp ) { |
474 | | - foreach ( array( $comment, $commenterName, $commenterURL ) as $field ) { |
475 | | - if ( preg_match( $sp, $field ) ) return $isspam = true; |
| 480 | + foreach ( $fields as $field ) { |
| 481 | + if ( preg_match( $sp, $field ) ) { echo "Is spam! "; |
| 482 | + $isspam = true; |
| 483 | + return true; |
| 484 | + } |
476 | 485 | } |
477 | 486 | } |
478 | 487 | |
479 | 488 | # Check for bad input for commenterName (seems to be a popular spam location) |
| 489 | + # These patterns are more general than those above |
480 | 490 | $spampatterns = array( |
481 | 491 | '%<a\\s+%smi', |
482 | 492 | '%(https?|ftp)://%smi', |
483 | 493 | '%(\\n|\\r)%smi' |
484 | 494 | ); |
485 | | - foreach ( $spampatterns as $sp ) if ( preg_match( $sp, $commenterName ) ) return $isspam = true; |
| 495 | + foreach ( $spampatterns as $sp ) { |
| 496 | + if ( preg_match( $sp, $commenterName ) ) { |
| 497 | + $isspam = true; |
| 498 | + return true; |
| 499 | + } |
| 500 | + } |
486 | 501 | |
487 | 502 | # Fail for length violations |
488 | | - if ( strlen( $commenterName ) > 255 || strlen( $commenterURL ) > 300 ) return $isspam = true; |
| 503 | + if ( strlen( $commenterName ) > 255 || strlen( $commenterURL ) > 300 ) { |
| 504 | + $isspam = true; |
| 505 | + return true; |
| 506 | + } |
489 | 507 | |
490 | 508 | # We made it this far, leave $isspam alone and give other implementors a chance. |
491 | 509 | return true; |