http://www.mediawiki.org/wiki/Special:Code/MediaWiki/74157
Revision: 74157
Author: platonides
Date: 2010-10-02 21:38:59 +0000 (Sat, 02 Oct 2010)
Log Message:
-----------
Fix to r74152: do not check the url when not provided.
Do not piggyback $isspam and the return value. They have different meanings.
Modified Paths:
--------------
trunk/extensions/ArticleComments/ArticleComments.php
Modified: trunk/extensions/ArticleComments/ArticleComments.php
===================================================================
--- trunk/extensions/ArticleComments/ArticleComments.php 2010-10-02
21:35:00 UTC (rev 74156)
+++ trunk/extensions/ArticleComments/ArticleComments.php 2010-10-02
21:38:59 UTC (rev 74157)
@@ -316,7 +316,7 @@
if ( !$commenterName ) $messages[] = wfMsgForContent(
'article-comments-required-field', wfMsgForContent(
'article-comments-name-string' ) );
- if ( !preg_match( "/^(" . wfUrlProtocols() . ')' .
Parser::EXT_LINK_URL_CLASS . '+$/', $commenterURL ) )
+ if ( ( $commenterURL != '' ) && !preg_match( "/^(" . wfUrlProtocols() .
')' . Parser::EXT_LINK_URL_CLASS . '+$/', $commenterURL ) )
$messages[] = wfMsgForContent(
'article-comments-invalid-field', wfMsgForContent(
'article-comments-url-string' ), $commenterURL );
@@ -450,17 +450,23 @@
* @param Boolean $isspam Whether the comment is spam (passed by reference)
* @return Boolean Always true to indicate other hooking methods may continue
to check for spam.
*/
-function defaultArticleCommentSpamCheck( $comment, $commenterName,
$commenterURL, $isspam ) {
+function defaultArticleCommentSpamCheck( $comment, $commenterName,
$commenterURL, &$isspam ) {
- # Short-circuit if spam has already been determined
- if ( $isspam ) return true;
+ if ( $isspam ) {
+ # This module only marks comments as spam (other modules may
unspam)
+ return true;
+ }
+
$fields = array( $comment, $commenterName, $commenterURL );
# Run everything through $wgSpamRegex if it has been specified
global $wgSpamRegex;
if ( $wgSpamRegex ) {
foreach ( $fields as $field ) {
- if ( preg_match( $wgSpamRegex, $field ) ) return
$isspam = true;
+ if ( preg_match( $wgSpamRegex, $field ) ) {
+ $isspam = true;
+ return true;
+ }
}
}
@@ -470,21 +476,33 @@
'%<a\\s+[^>]*href\\s*=\\s*[\'"]?\\s*(https?|ftp)://%smi'
);
foreach ( $spampatterns as $sp ) {
- foreach ( array( $comment, $commenterName, $commenterURL ) as
$field ) {
- if ( preg_match( $sp, $field ) ) return $isspam = true;
+ foreach ( $fields as $field ) {
+ if ( preg_match( $sp, $field ) ) { echo "Is spam! ";
+ $isspam = true;
+ return true;
+ }
}
}
# Check for bad input for commenterName (seems to be a popular spam
location)
+ # These patterns are more general than those above
$spampatterns = array(
'%<a\\s+%smi',
'%(https?|ftp)://%smi',
'%(\\n|\\r)%smi'
);
- foreach ( $spampatterns as $sp ) if ( preg_match( $sp, $commenterName )
) return $isspam = true;
+ foreach ( $spampatterns as $sp ) {
+ if ( preg_match( $sp, $commenterName ) ) {
+ $isspam = true;
+ return true;
+ }
+ }
# Fail for length violations
- if ( strlen( $commenterName ) > 255 || strlen( $commenterURL ) > 300 )
return $isspam = true;
+ if ( strlen( $commenterName ) > 255 || strlen( $commenterURL ) > 300 ) {
+ $isspam = true;
+ return true;
+ }
# We made it this far, leave $isspam alone and give other implementors
a chance.
return true;
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs