From bf29da39d9e10efa8ac88d79d1eabf7ce147f0ca Mon Sep 17 00:00:00 2001 From: "Anthony G. Basile" Date: Mon, 6 Jan 2020 14:37:59 -0500 Subject: Update akismet 4.1.3 Signed-off-by: Anthony G. Basile --- plugins/akismet.4.1.3.zip | Bin 0 -> 73019 bytes plugins/akismet/_inc/akismet.css | 38 ++++++++++++ plugins/akismet/_inc/akismet.js | 64 ++++++++++++++++--- plugins/akismet/akismet.php | 4 +- plugins/akismet/class.akismet-admin.php | 27 +++++++- plugins/akismet/class.akismet.php | 2 + plugins/akismet/readme.txt | 16 +++-- plugins/akismet/views/activate.php | 8 +++ plugins/akismet/views/connect-jp.php | 72 +++++++++++++++++++++ plugins/akismet/views/enter.php | 13 ++++ plugins/akismet/views/notice.php | 8 ++- plugins/akismet/views/predefined.php | 11 ++++ plugins/akismet/views/setup.php | 5 ++ plugins/akismet/views/start.php | 107 ++++++-------------------------- plugins/akismet/views/title.php | 3 + 15 files changed, 271 insertions(+), 107 deletions(-) create mode 100644 plugins/akismet.4.1.3.zip create mode 100644 plugins/akismet/views/activate.php create mode 100644 plugins/akismet/views/connect-jp.php create mode 100644 plugins/akismet/views/enter.php create mode 100644 plugins/akismet/views/predefined.php create mode 100644 plugins/akismet/views/setup.php create mode 100644 plugins/akismet/views/title.php diff --git a/plugins/akismet.4.1.3.zip b/plugins/akismet.4.1.3.zip new file mode 100644 index 00000000..2c80e73f Binary files /dev/null and b/plugins/akismet.4.1.3.zip differ diff --git a/plugins/akismet/_inc/akismet.css b/plugins/akismet/_inc/akismet.css index bc56f061..fea4eb7b 100644 --- a/plugins/akismet/_inc/akismet.css +++ b/plugins/akismet/_inc/akismet.css @@ -546,6 +546,44 @@ table.comments td.comment p a:after { margin-top: 1.5rem; } +.akismet-box-header { + max-width: 700px; + margin: 0 auto 40px auto; + line-height: 1.5; +} + +.akismet-box-header h2 { + margin: 1.5rem 10% 0; + font-size: 1.375rem; + font-weight: 700; + color: #000; +} + +.akismet-box .centered { + text-align: center; +} + +.akismet-enter-api-key-box { + margin: 1.5rem 0; +} + +.akismet-box .enter-api-key { + display: none; + margin-top: 1.5rem; +} + +.akismet-box .akismet-toggles { + margin: 3rem 0; +} + +.akismet-box .akismet-ak-connect, .akismet-box .toggle-jp-connect { + display: none; +} + +.akismet-box .enter-api-key p { + padding: 0 1.5rem; +} + .akismet-button, .akismet-button:hover, .akismet-button:visited { background: white; border-color: #c8d7e1; diff --git a/plugins/akismet/_inc/akismet.js b/plugins/akismet/_inc/akismet.js index 6cb85e6c..3445a094 100644 --- a/plugins/akismet/_inc/akismet.js +++ b/plugins/akismet/_inc/akismet.js @@ -169,6 +169,8 @@ jQuery( function ( $ ) { function akismet_check_for_spam(offset, limit) { var check_for_spam_buttons = $( '.checkforspam' ); + var nonce = check_for_spam_buttons.data( 'nonce' ); + // We show the percentage complete down to one decimal point so even queues with 100k // pending comments will show some progress pretty quickly. var percentage_complete = Math.round( ( recheck_count / check_for_spam_buttons.data( 'pending-comment-count' ) ) * 1000 ) / 10; @@ -181,9 +183,16 @@ jQuery( function ( $ ) { { 'action': 'akismet_recheck_queue', 'offset': offset, - 'limit': limit + 'limit': limit, + 'nonce': nonce }, function(result) { + if ( 'error' in result ) { + // An error is only returned in the case of a missing nonce, so we don't need the actual error message. + window.location.href = check_for_spam_buttons.data( 'failure-url' ); + return; + } + recheck_count += result.counts.processed; spam_count += result.counts.spam; @@ -282,27 +291,64 @@ jQuery( function ( $ ) { /** * Sets the comment form privacy notice display to hide when one clicks Core's dismiss button on the related admin notice. */ - $( '#akismet-privacy-notice-admin-notice' ).on( 'click', '.notice-dismiss', function(){ - $.ajax({ - url: './options-general.php?page=akismet-key-config&akismet_comment_form_privacy_notice=hide', - }); + $( '#akismet-privacy-notice-admin-notice' ).on( 'click', '.notice-dismiss', function () { + $.ajax( { + url: './options-general.php?page=akismet-key-config&akismet_comment_form_privacy_notice=hide', + } ); }); - $( ".akismet-could-be-primary" ).each( function () { + $( '.akismet-could-be-primary' ).each( function () { var form = $( this ).closest( 'form' ); form.data( 'initial-state', form.serialize() ); form.on( 'change keyup', function () { var self = $( this ); - var submit_button = self.find( ".akismet-could-be-primary" ); + var submit_button = self.find( '.akismet-could-be-primary' ); if ( self.serialize() != self.data( 'initial-state' ) ) { - submit_button.addClass( "akismet-is-primary" ); + submit_button.addClass( 'akismet-is-primary' ); } else { - submit_button.removeClass( "akismet-is-primary" ); + submit_button.removeClass( 'akismet-is-primary' ); } } ); } ); + + /** + * Shows the Enter API key form + */ + $( '.akismet-enter-api-key-box a' ).on( 'click', function ( e ) { + e.preventDefault(); + + var div = $( '.enter-api-key' ); + div.show( 500 ); + div.find( 'input[name=key]' ).focus(); + + $( this ).hide(); + } ); + + /** + * Hides the Connect with Jetpack form | Shows the Activate Akismet Account form + */ + $( 'a.toggle-ak-connect' ).on( 'click', function ( e ) { + e.preventDefault(); + + $( '.akismet-ak-connect' ).slideToggle('slow'); + $( 'a.toggle-ak-connect' ).hide(); + $( '.akismet-jp-connect' ).hide(); + $( 'a.toggle-jp-connect' ).show(); + } ); + + /** + * Shows the Connect with Jetpack form | Hides the Activate Akismet Account form + */ + $( 'a.toggle-jp-connect' ).on( 'click', function ( e ) { + e.preventDefault(); + + $( '.akismet-jp-connect' ).slideToggle('slow'); + $( 'a.toggle-jp-connect' ).hide(); + $( '.akismet-ak-connect' ).hide(); + $( 'a.toggle-ak-connect' ).show(); + } ); }); diff --git a/plugins/akismet/akismet.php b/plugins/akismet/akismet.php index 49608e5a..538a7dbc 100644 --- a/plugins/akismet/akismet.php +++ b/plugins/akismet/akismet.php @@ -6,7 +6,7 @@ Plugin Name: Akismet Anti-Spam Plugin URI: https://akismet.com/ Description: Used by millions, Akismet is quite possibly the best way in the world to protect your blog from spam. It keeps your site protected even while you sleep. To get started: activate the Akismet plugin and then go to your Akismet Settings page to set up your API key. -Version: 4.1.2 +Version: 4.1.3 Author: Automattic Author URI: https://automattic.com/wordpress-plugins/ License: GPLv2 or later @@ -37,7 +37,7 @@ if ( !function_exists( 'add_action' ) ) { exit; } -define( 'AKISMET_VERSION', '4.1.2' ); +define( 'AKISMET_VERSION', '4.1.3' ); define( 'AKISMET__MINIMUM_WP_VERSION', '4.0' ); define( 'AKISMET__PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); define( 'AKISMET_DELETE_LIMIT', 100000 ); diff --git a/plugins/akismet/class.akismet-admin.php b/plugins/akismet/class.akismet-admin.php index f0766ebe..b5e2ef8e 100644 --- a/plugins/akismet/class.akismet-admin.php +++ b/plugins/akismet/class.akismet-admin.php @@ -80,6 +80,13 @@ class Akismet_Admin { } public static function admin_init() { + if ( get_option( 'Activated_Akismet' ) ) { + delete_option( 'Activated_Akismet' ); + if ( ! headers_sent() ) { + wp_redirect( add_query_arg( array( 'page' => 'akismet-key-config', 'view' => 'start' ), class_exists( 'Jetpack' ) ? admin_url( 'admin.php' ) : admin_url( 'options-general.php' ) ) ); + } + } + load_plugin_textdomain( 'akismet' ); add_meta_box( 'akismet-status', __('Comment History', 'akismet'), array( 'Akismet_Admin', 'comment_status_meta_box' ), 'comment', 'normal' ); @@ -396,8 +403,10 @@ class Akismet_Admin { href="' . esc_url( $link ) . '" data-active-label="' . esc_attr( __( 'Checking for Spam', 'akismet' ) ) . '" data-progress-label-format="' . esc_attr( __( '(%1$s%)', 'akismet' ) ) . '" - data-success-url="' . esc_attr( remove_query_arg( 'akismet_recheck', add_query_arg( array( 'akismet_recheck_complete' => 1, 'recheck_count' => urlencode( '__recheck_count__' ), 'spam_count' => urlencode( '__spam_count__' ) ) ) ) ) . '" + data-success-url="' . esc_attr( remove_query_arg( array( 'akismet_recheck', 'akismet_recheck_error' ), add_query_arg( array( 'akismet_recheck_complete' => 1, 'recheck_count' => urlencode( '__recheck_count__' ), 'spam_count' => urlencode( '__spam_count__' ) ) ) ) ) . '" + data-failure-url="' . esc_attr( remove_query_arg( array( 'akismet_recheck', 'akismet_recheck_complete' ), add_query_arg( array( 'akismet_recheck_error' => 1 ) ) ) ) . '" data-pending-comment-count="' . esc_attr( $comments_count->moderated ) . '" + data-nonce="' . esc_attr( wp_create_nonce( 'akismet_check_for_spam' ) ) . '" >'; echo '' . esc_html__('Check for Spam', 'akismet') . ''; echo ''; @@ -414,6 +423,13 @@ class Akismet_Admin { if ( ! ( isset( $_GET['recheckqueue'] ) || ( isset( $_REQUEST['action'] ) && 'akismet_recheck_queue' == $_REQUEST['action'] ) ) ) { return; } + + if ( ! wp_verify_nonce( $_POST['nonce'], 'akismet_check_for_spam' ) ) { + wp_send_json( array( + 'error' => __( "You don't have permission to do that."), + )); + return; + } $result_counts = self::recheck_queue_portion( empty( $_POST['offset'] ) ? 0 : $_POST['offset'], empty( $_POST['limit'] ) ? 100 : $_POST['limit'] ); @@ -1061,6 +1077,9 @@ class Akismet_Admin { echo '

' . esc_html( $message ) . '

'; } + else if ( isset( $_GET['akismet_recheck_error'] ) ) { + echo '

' . esc_html( __( 'Akismet could not recheck your comments for spam.', 'akismet' ) ) . '

'; + } $akismet_comment_form_privacy_notice_option = get_option( 'akismet_comment_form_privacy_notice' ); if ( ! in_array( $akismet_comment_form_privacy_notice_option, array( 'hide', 'display' ) ) ) { @@ -1108,7 +1127,11 @@ class Akismet_Admin { if ( !class_exists('Jetpack') ) return false; - Jetpack::load_xml_rpc_client(); + if ( defined( 'JETPACK__VERSION' ) && version_compare( JETPACK__VERSION, '7.7', '<' ) ) { + // For version of Jetpack prior to 7.7. + Jetpack::load_xml_rpc_client(); + } + $xml = new Jetpack_IXR_ClientMulticall( array( 'user_id' => get_current_user_id() ) ); $xml->addCall( 'wpcom.getUserID' ); diff --git a/plugins/akismet/class.akismet.php b/plugins/akismet/class.akismet.php index f24fd63d..01753014 100644 --- a/plugins/akismet/class.akismet.php +++ b/plugins/akismet/class.akismet.php @@ -1277,6 +1277,8 @@ p { $message = ''.sprintf(esc_html__( 'Akismet %s requires WordPress %s or higher.' , 'akismet'), AKISMET_VERSION, AKISMET__MINIMUM_WP_VERSION ).' '.sprintf(__('Please upgrade WordPress to a current version, or downgrade to version 2.4 of the Akismet plugin.', 'akismet'), 'https://codex.wordpress.org/Upgrading_WordPress', 'https://wordpress.org/extend/plugins/akismet/download/'); Akismet::bail_on_activation( $message ); + } else { + add_option( 'Activated_Akismet', true ); } } diff --git a/plugins/akismet/readme.txt b/plugins/akismet/readme.txt index 15526e9a..bf0081a9 100644 --- a/plugins/akismet/readme.txt +++ b/plugins/akismet/readme.txt @@ -2,8 +2,8 @@ Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, eoigal, cfinke, automattic, jgs, procifer, stephdau Tags: akismet, comments, spam, antispam, anti-spam, anti spam, comment moderation, comment spam, contact form spam, spam comments Requires at least: 4.0 -Tested up to: 5.2 -Stable tag: 4.1.2 +Tested up to: 5.3 +Stable tag: 4.1.3 License: GPLv2 or later Akismet checks your comments and contact form submissions against our global database of spam to protect you and your site from malicious content. @@ -20,16 +20,24 @@ Major features in Akismet include: * Moderators can see the number of approved comments for each user. * A discard feature that outright blocks the worst spam, saving you disk space and speeding up your site. -PS: You'll need an [Akismet.com API key](https://akismet.com/get/) to use it. Keys are free for personal blogs; paid subscriptions are available for businesses and commercial sites. +PS: You'll be prompted to get an Akismet.com API key to use it, once activated. Keys are free for personal blogs; paid subscriptions are available for businesses and commercial sites. == Installation == -Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.com API key](https://akismet.com/get/). +Upload the Akismet plugin to your blog, activate it, and then enter your Akismet.com API key. 1, 2, 3: You're done! == Changelog == += 4.1.3 = +*Release Date - 31 October 2019* + +* Prevented an attacker from being able to cause a user to unknowingly recheck their Pending comments for spam. +* Improved compatibility with Jetpack 7.7+. +* Updated the plugin activation page to use consistent language and markup. +* Redirecting users to the Akismet connnection/settings screen upon plugin activation, in an effort to make it easier for people to get setup. + = 4.1.2 = *Release Date - 14 May 2019* diff --git a/plugins/akismet/views/activate.php b/plugins/akismet/views/activate.php new file mode 100644 index 00000000..7be1309c --- /dev/null +++ b/plugins/akismet/views/activate.php @@ -0,0 +1,8 @@ +
+ + +
+
+
+ +
\ No newline at end of file diff --git a/plugins/akismet/views/connect-jp.php b/plugins/akismet/views/connect-jp.php new file mode 100644 index 00000000..5b33999a --- /dev/null +++ b/plugins/akismet/views/connect-jp.php @@ -0,0 +1,72 @@ + +
+ +
+

status, array( 'no-sub', 'missing' ) ) ) {?> +

+
+ + + + + +
+ user_email, null, null, null, array( 'class' => 'akismet-jetpack-gravatar' ) ); ?> +

' . esc_html( $akismet_user->user_login ) . '' ); ?>
user_email ); ?>

+ status == 'cancelled' ) { ?> +

+
+ + + + + +
+ user_email, null, null, null, array( 'class' => 'akismet-jetpack-gravatar' ) ); ?> +

user_email ) ); ?>
user_email ); ?>

+ status == 'suspended' ) { ?> +
+

+
+

+ user_email ) ); ?> + +

+ +

+
+ + + + +
+ user_email, null, null, null, array( 'class' => 'akismet-jetpack-gravatar' ) ); ?> +

' . esc_html( $akismet_user->user_login ) . '' ); ?>
user_email ); ?>

+ +
+
+ +
+
+ + +
+
+
+
+ +
\ No newline at end of file diff --git a/plugins/akismet/views/enter.php b/plugins/akismet/views/enter.php new file mode 100644 index 00000000..0a79ca97 --- /dev/null +++ b/plugins/akismet/views/enter.php @@ -0,0 +1,13 @@ +
+ +
+
+ + +

+ + +

+
+
+
\ No newline at end of file diff --git a/plugins/akismet/views/notice.php b/plugins/akismet/views/notice.php index 7f70fc12..fa098b8b 100644 --- a/plugins/akismet/views/notice.php +++ b/plugins/akismet/views/notice.php @@ -1,3 +1,9 @@ +
@@ -138,4 +144,4 @@

enable or disable this feature. More information.', 'akismet' ), admin_url( apply_filters( 'akismet_comment_form_privacy_notice_url_display', 'options-general.php?page=akismet-key-config&akismet_comment_form_privacy_notice=display' ) ), admin_url( apply_filters( 'akismet_comment_form_privacy_notice_url_hide', 'options-general.php?page=akismet-key-config&akismet_comment_form_privacy_notice=hide' ) ), 'https://akismet.com/privacy/' ); ?>

- + \ No newline at end of file diff --git a/plugins/akismet/views/predefined.php b/plugins/akismet/views/predefined.php new file mode 100644 index 00000000..d978aaff --- /dev/null +++ b/plugins/akismet/views/predefined.php @@ -0,0 +1,11 @@ +
+

+

+ wp-config.php' ); + + ?> +

+
\ No newline at end of file diff --git a/plugins/akismet/views/setup.php b/plugins/akismet/views/setup.php new file mode 100644 index 00000000..d21c89a9 --- /dev/null +++ b/plugins/akismet/views/setup.php @@ -0,0 +1,5 @@ +

+
+ __( 'Set up your Akismet account' , 'akismet' ), 'classes' => array( 'akismet-button', 'akismet-is-primary' ) ) ); ?> +
+

\ No newline at end of file diff --git a/plugins/akismet/views/start.php b/plugins/akismet/views/start.php index 0ec35fdb..aaff5d66 100644 --- a/plugins/akismet/views/start.php +++ b/plugins/akismet/views/start.php @@ -1,3 +1,9 @@ +
@@ -7,96 +13,19 @@
- - -
-

-

-
+
- - status, array( 'active', 'active-dunning', 'no-sub', 'missing', 'cancelled', 'suspended' ) ) ) { ?> - status, array( 'no-sub', 'missing' ) ) ) { ?> -
-

-

- - - - - - - - user_email, null, null, null, array( 'class' => 'akismet-jetpack-gravatar' ) ); ?> -

' . esc_html( $akismet_user->user_login ) . '' ); ?>
user_email ); ?>

-
- status == 'cancelled' ) { ?> -
-

-
- - - - - -
-

user_email ) ); ?>

-
- status == 'suspended' ) { ?> -
-

-

user_email ) ); ?>

-

-

-
- -
-

-

-
- - - - -
- user_email, null, null, null, array( 'class' => 'akismet-jetpack-gravatar' ) ); ?> -

' . esc_html( $akismet_user->user_login ) . '' ); ?>
user_email ); ?>

-
- -
-

-
- __( 'Sign up with a different email address' , 'akismet' ), 'classes' => array( 'akismet-button' ) ) ); ?> -
-

-
- -
-

-
- __( 'Get your API key' , 'akismet' ), 'classes' => array( 'akismet-button', 'akismet-is-primary' ) ) ); ?> -
-

-
- -
-

-

-
- - -

- - -

-
-
- -
-

-

wp-config.php' ); ?>

-
- + status, array( 'active', 'active-dunning', 'no-sub', 'missing', 'cancelled', 'suspended' ) ) ) { + Akismet::view( 'connect-jp', compact( 'akismet_user' ) ); + } else { + Akismet::view( 'activate' ); + } + + ?>
\ No newline at end of file diff --git a/plugins/akismet/views/title.php b/plugins/akismet/views/title.php new file mode 100644 index 00000000..b5abb414 --- /dev/null +++ b/plugins/akismet/views/title.php @@ -0,0 +1,3 @@ +
+

+
\ No newline at end of file -- cgit v1.2.3-65-gdbad