]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-content/plugins/akismet/class.akismet.php
WordPress 4.4.1
[autoinstalls/wordpress.git] / wp-content / plugins / akismet / class.akismet.php
index 7a637386d0674ded435c889389a8fbb12a7480f5..e47c8a8f186db42e228cf06a1e2d244f9895d5a7 100644 (file)
@@ -29,6 +29,14 @@ class Akismet {
                add_action( 'akismet_scheduled_delete', array( 'Akismet', 'delete_old_comments_meta' ) );
                add_action( 'akismet_schedule_cron_recheck', array( 'Akismet', 'cron_recheck' ) );
 
+               /**
+                * To disable the Akismet comment nonce, add a filter for the 'akismet_comment_nonce' tag
+                * and return any string value that is not 'true' or '' (empty string).
+                *
+                * Don't return boolean false, because that implies that the 'akismet_comment_nonce' option
+                * has not been set and that Akismet should just choose the default behavior for that
+                * situation.
+                */
                $akismet_comment_nonce_option = apply_filters( 'akismet_comment_nonce', get_option( 'akismet_comment_nonce' ) );
 
                if ( $akismet_comment_nonce_option == 'true' || $akismet_comment_nonce_option == '' )
@@ -45,12 +53,6 @@ class Akismet {
 
                // Run this early in the pingback call, before doing a remote fetch of the source uri
                add_action( 'xmlrpc_call', array( 'Akismet', 'pre_check_pingback' ) );
-
-               if ( '3.0.5' == $GLOBALS['wp_version'] ) {
-                       remove_filter( 'comment_text', 'wp_kses_data' );
-                       if ( is_admin() )
-                               add_filter( 'comment_text', 'wp_kses_post' );
-               }
        }
 
        public static function get_api_key() {
@@ -95,6 +97,7 @@ class Akismet {
                if ( !empty( $comment['user_ID'] ) )
                        $comment['user_role'] = Akismet::get_user_roles( $comment['user_ID'] );
 
+               /** See filter documentation in init_hooks(). */
                $akismet_nonce_option = apply_filters( 'akismet_comment_nonce', get_option( 'akismet_comment_nonce' ) );
                $comment['akismet_comment_nonce'] = 'inactive';
                if ( $akismet_nonce_option == 'true' || $akismet_nonce_option == '' ) {
@@ -708,14 +711,19 @@ class Akismet {
                           isset( $comment1['comment_post_ID'], $comment2['comment_post_ID'] )
                        && intval( $comment1['comment_post_ID'] ) == intval( $comment2['comment_post_ID'] )
                        && (
-                               $comment1['comment_author'] == $comment2['comment_author']
-                               || stripslashes( $comment1['comment_author'] ) == $comment2['comment_author']
-                               || $comment1['comment_author'] == stripslashes( $comment2['comment_author'] )
+                               // The comment author length max is 255 characters, limited by the TINYTEXT column type.
+                               substr( $comment1['comment_author'], 0, 255 ) == substr( $comment2['comment_author'], 0, 255 )
+                               || substr( stripslashes( $comment1['comment_author'] ), 0, 255 ) == substr( $comment2['comment_author'], 0, 255 )
+                               || substr( $comment1['comment_author'], 0, 255 ) == substr( stripslashes( $comment2['comment_author'] ), 0, 255 )
                                )
                        && (
-                               $comment1['comment_author_email'] == $comment2['comment_author_email']
-                               || stripslashes( $comment1['comment_author_email'] ) == $comment2['comment_author_email']
-                               || $comment1['comment_author_email'] == stripslashes( $comment2['comment_author_email'] )
+                               // The email max length is 100 characters, limited by the VARCHAR(100) column type.
+                               substr( $comment1['comment_author_email'], 0, 100 ) == substr( $comment2['comment_author_email'], 0, 100 )
+                               || substr( stripslashes( $comment1['comment_author_email'] ), 0, 100 ) == substr( $comment2['comment_author_email'], 0, 100 )
+                               || substr( $comment1['comment_author_email'], 0, 100 ) == substr( stripslashes( $comment2['comment_author_email'] ), 0, 100 )
+                               // Very long emails can be truncated and then stripped if the [0:100] substring isn't a valid address.
+                               || ( ! $comment1['comment_author_email'] && strlen( $comment2['comment_author_email'] ) > 100 )
+                               || ( ! $comment2['comment_author_email'] && strlen( $comment1['comment_author_email'] ) > 100 )
                        )
                );
        }