Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/customer-reviews-woocommerce/class-ivole.php
+++ b/customer-reviews-woocommerce/class-ivole.php
@@ -85,7 +85,7 @@
require_once( __DIR__ . '/includes/analytics/class-cr-reviews-top-charts.php' );
class Ivole {
- const CR_VERSION = '5.115.0';
+ const CR_VERSION = '5.116.0';
public function __construct() {
if( function_exists( 'wc' ) ) {
--- a/customer-reviews-woocommerce/includes/blocks/class-cr-reviews-slider.php
+++ b/customer-reviews-woocommerce/includes/blocks/class-cr-reviews-slider.php
@@ -247,7 +247,7 @@
$num_reviews = count( $reviews );
if ( $num_reviews < 1 ) {
- return __( 'No reviews to show', 'customer-reviews-woocommerce' );
+ return '<div class="cr-no-reviews">' . esc_html__( 'No reviews to show', 'customer-reviews-woocommerce' ) . '</div>';
}
$show_products = $attributes['show_products'];
--- a/customer-reviews-woocommerce/includes/google/class-cr-google-shopping-prod-feed.php
+++ b/customer-reviews-woocommerce/includes/google/class-cr-google-shopping-prod-feed.php
@@ -610,10 +610,10 @@
if ( $product->is_on_backorder() ) {
$_product->availability = 'backorder';
} else {
- $_product->availability = 'in stock';
+ $_product->availability = 'in_stock';
}
} else {
- $_product->availability = 'out of stock';
+ $_product->availability = 'out_of_stock';
}
$_product->availability = apply_filters(
'cr_gs_product_feed_availability',
--- a/customer-reviews-woocommerce/includes/qna/class-cr-qna-email.php
+++ b/customer-reviews-woocommerce/includes/qna/class-cr-qna-email.php
@@ -20,6 +20,8 @@
private $template_name = '';
private $find = array();
private $replace = array();
+ private $color_bg = '#0f9d58';
+ private $color_text = '#ffffff';
public static $qna_reply_def_body = "Hi {customer_name},nn{user_name} responded to your question about <b>{product_name}</b>. Here is a copy of their response:nn<i>{answer}</i>nnYou can view <b>{product_name}</b> here:nn{product_button}nnBest wishes,nAtomic Edge Team";
@@ -40,12 +42,14 @@
$this->replace['product-name'] = '';
$this->replace['product-link'] = '';
$this->replace['answer'] = '';
+ $this->color_bg = get_option( 'ivole_email_qna_color_bg', '#0f9d58' );
+ $this->color_text = get_option( 'ivole_email_qna_color_text', '#ffffff' );
$this->replace['product-button'] = apply_filters(
'cr_qna_email_product_button',
'<table border="0" cellspacing="0" cellpadding="0" style="margin-top: 30px; margin-bottom: 30px;">' .
'<tr>' .
- '<td align="center" style="border-radius: 5px; background-color: #0f9d58;">' .
- '<a rel="noopener" target="_blank" href="{product_link}" target="_blank" style="float: left; font-size: 14px; font-family: Helvetica, Arial, sans-serif; color: #ffffff; font-weight: bold; text-decoration: none; border-radius: 5px; padding: 12px 18px; border: 1px solid #0f9d58; background-color: #0f9d58;">{product_name}</a>' .
+ '<td align="center" style="border-radius: 5px; background-color: ' . esc_attr( $this->color_bg ) . ';">' .
+ '<a rel="noopener" target="_blank" href="{product_link}" target="_blank" style="float: left; font-size: 14px; font-family: Helvetica, Arial, sans-serif; color: ' . esc_attr( $this->color_text ) . '; font-weight: bold; text-decoration: none; border-radius: 5px; padding: 12px 18px; border: 1px solid ' . esc_attr( $this->color_bg ) . '; background-color: ' . esc_attr( $this->color_bg ) . ';">{product_name}</a>' .
'</td>' .
'</tr>' .
'</table>'
@@ -103,10 +107,10 @@
$this->subject = $this->replace_variables( $this->subject );
$this->message = $this->get_email_template();
$result = $this->send_email( $to );
- if( $result ) {
+ if ( $result ) {
return 0;
} else {
- return -1;
+ return array( -1, __( 'wp_mail failed to send test email', 'customer-reviews-woocommerce' ) );
}
}
@@ -125,6 +129,8 @@
$cr_email_heading = $this->replace_variables( $this->heading );
$cr_email_body = $this->replace_variables( $this->body );
$cr_email_footer = Ivole_Email::get_blogname();
+ $cr_email_color_bg = $this->color_bg;
+ $cr_email_color_text = $this->color_text;
include( $template );
$email_template = ob_get_clean();
return $email_template;
--- a/customer-reviews-woocommerce/includes/reminders/class-cr-local-forms.php
+++ b/customer-reviews-woocommerce/includes/reminders/class-cr-local-forms.php
@@ -20,6 +20,7 @@
private $cr_form_color3;
private $language;
private $extra;
+ private $currency;
const HEADER_TEMPLATE = 'form-header.php';
const ITEM_BLOCK_TEMPLATE = 'form-block-item.php';
@@ -389,7 +390,7 @@
$formId = self::TEST_FORM;
} else {
// generate unique form id
- $formId = strtolower( uniqid() );
+ $formId = strtolower( self::generate_unique_id() );
}
// get currency
@@ -525,6 +526,18 @@
}
}
+ public static function generate_unique_id() {
+ // 1. Generate 7 random bytes (which converts to 14 hex characters)
+ $randomBytes = random_bytes(7);
+
+ // 2. Convert bytes to a hexadecimal string
+ $hexString = bin2hex($randomBytes);
+
+ // 3. Trim to exactly 13 characters to match uniqid() length
+ return substr($hexString, 0, 13);
+ }
+
+
}
endif;
--- a/customer-reviews-woocommerce/includes/settings/class-cr-admin-menu-settings.php
+++ b/customer-reviews-woocommerce/includes/settings/class-cr-admin-menu-settings.php
@@ -135,6 +135,7 @@
'cr-admin-settings',
'cr_settings_object',
array(
+ 'settings_nonce' => wp_create_nonce( 'cr-settings-ajax' ),
'checking' => __( 'Checking...', 'customer-reviews-woocommerce' ),
'checking_license' => __( 'Checking license...', 'customer-reviews-woocommerce' ),
'yes' => __( 'Yes', 'customer-reviews-woocommerce' ),
@@ -722,15 +723,37 @@
* Function to check status of the license
*/
public function check_license_ajax() {
+ // capability check
+ if ( ! current_user_can( apply_filters( 'cr_settings_permissions', 'manage_options' ) ) ) {
+ wp_send_json( array( 'code' => -10, 'message' => __( 'Permission denied', 'customer-reviews-woocommerce' ) ) );
+ wp_die();
+ }
+
+ // nonce verification
+ if ( ! check_ajax_referer( 'cr-settings-ajax', 'nonce', false ) ) {
+ wp_send_json( array( 'code' => -11, 'message' => __( 'Error: nonce expired, please reload the page and try again', 'customer-reviews-woocommerce' ) ) );
+ wp_die();
+ }
+
$license = new CR_License();
$lval = $license->check_license();
wp_send_json( array( 'code' => $lval['code'], 'message' => $lval['info'] ) );
}
public function download_addon() {
- $res = array(
- 'url' => ''
- );
+ $res = array( 'url' => '' );
+
+ // capability check
+ if ( ! current_user_can( apply_filters( 'cr_settings_permissions', 'manage_options' ) ) ) {
+ wp_send_json( $res );
+ wp_die();
+ }
+
+ // nonce verification
+ if ( ! check_ajax_referer( 'cr-settings-ajax', 'nonce', false ) ) {
+ wp_send_json( $res );
+ wp_die();
+ }
$license_key = trim( get_option( 'ivole_license_key', '' ) );
if ( $license_key ) {
@@ -888,9 +911,22 @@
public function hide_banner() {
$res = 1;
+
+ // capability check
+ if ( ! current_user_can( apply_filters( 'cr_settings_permissions', 'manage_options' ) ) ) {
+ wp_send_json( $res );
+ wp_die();
+ }
+
+ // nonce verification
+ if ( ! check_ajax_referer( 'cr-settings-ajax', 'nonce', false ) ) {
+ wp_send_json( $res );
+ wp_die();
+ }
+
$hidden_banners = get_option( 'ivole_hidden_banners', array() );
- if( isset( $_POST['banner'] ) && $_POST['banner'] ) {
- $hidden_banners[$_POST['banner']] = 1;
+ if ( isset( $_POST['banner'] ) && $_POST['banner'] ) {
+ $hidden_banners[sanitize_text_field( wp_unslash( $_POST['banner'] ) )] = 1;
update_option( 'ivole_hidden_banners', $hidden_banners, false );
$res = 0;
}
--- a/customer-reviews-woocommerce/includes/settings/class-cr-settings-cusrev.php
+++ b/customer-reviews-woocommerce/includes/settings/class-cr-settings-cusrev.php
@@ -25,7 +25,6 @@
add_action( 'woocommerce_admin_field_twocolsmode', array( $this, 'show_twocolsmode' ) );
add_action( 'ivole_settings_display_' . $this->tab, array( $this, 'display' ) );
add_action( 'cr_save_settings_' . $this->tab, array( $this, 'save' ) );
- add_action( 'admin_footer', array( $this, 'output_page_javascript' ) );
add_action( 'wp_ajax_cr_check_age_restriction_ajax', array( $this, 'check_verified_reviews_ajax' ) );
add_action( 'woocommerce_admin_settings_sanitize_option_ivole_verified_live_mode', array( $this, 'save_live_mode' ), 10, 3 );
add_action( 'woocommerce_admin_settings_sanitize_option_ivole_age_restriction', array( $this, 'save_age_restriction_checkbox' ), 10, 3 );
@@ -205,6 +204,16 @@
* Function to check if age restriction is enabled
*/
public function check_verified_reviews_ajax() {
+ if ( ! current_user_can( apply_filters( 'cr_settings_permissions', 'manage_options' ) ) ) {
+ wp_send_json( array( 'status' => 0 ) );
+ wp_die();
+ }
+
+ if ( ! check_ajax_referer( 'cr-settings-ajax', 'nonce', false ) ) {
+ wp_send_json( array( 'status' => 0 ) );
+ wp_die();
+ }
+
$vrevs = new CR_Verified_Reviews();
$rval = $vrevs->check_status();
@@ -215,30 +224,6 @@
}
}
- public function output_page_javascript() {
- if ( $this->is_this_tab() ) {
- ?>
- <script type="text/javascript">
- jQuery(function($) {
- // check age restriction setting
- if ( jQuery('#ivole_age_restriction').length > 0 ) {
- let data = {
- 'action': 'cr_check_age_restriction_ajax'
- };
- jQuery('.cr-verified-badge-status').text('Checking settings...');
- jQuery('.cr-verified-badge-status').css('visibility', 'visible');
- jQuery.post(ajaxurl, data, function(response) {
- jQuery('.cr-verified-badge-status').css( 'visibility', 'hidden' );
- jQuery('.cr-disabled-checkbox').prop( 'disabled', false );
- jQuery('#ivole_age_restriction').prop( 'checked', <?php echo 'yes' === get_option( 'ivole_age_restriction', 'no' ) ? 'true' : 'false'; ?> );
- });
- }
- });
- </script>
- <?php
- }
- }
-
public function show_twocolsmode( $value ) {
$tmp = CR_Admin::cr_get_field_description( $value );
$tooltip_html = $tmp['tooltip_html'];
--- a/customer-reviews-woocommerce/includes/settings/class-cr-settings-email-template.php
+++ b/customer-reviews-woocommerce/includes/settings/class-cr-settings-email-template.php
@@ -523,7 +523,7 @@
$this->name,
apply_filters(
'cr_settings_email_colors',
- array( 'review_reminder', 'review_discount' )
+ array( 'review_reminder', 'review_discount', 'qna_reply' )
)
)
) {
@@ -538,6 +538,11 @@
$desc = __( 'Background color for heading of the email.', 'customer-reviews-woocommerce' );
$class = 'cr_email_coupon_color_bg';
break;
+ case 'qna_reply':
+ $id = 'ivole_email_qna_color_bg';
+ $desc = __( 'Background color for the Q&A reply email header and action button.', 'customer-reviews-woocommerce' );
+ $class = 'cr_email_qna_color_bg';
+ break;
default:
$id = '';
$desc = '';
@@ -565,6 +570,11 @@
$desc = __( 'Text color for heading of the email.', 'customer-reviews-woocommerce' );
$class = 'cr_email_coupon_color_text';
break;
+ case 'qna_reply':
+ $id = 'ivole_email_qna_color_text';
+ $desc = __( 'Text color for the Q&A reply email header and action button.', 'customer-reviews-woocommerce' );
+ $class = 'cr_email_qna_color_text';
+ break;
default:
$id = '';
$desc = '';
@@ -720,29 +730,39 @@
}
public function save_fields() {
- if( ! empty( $_POST ) && isset( $_POST['ivole_email_body'] ) ) {
- if( empty( preg_replace( '#s#isUu', '', html_entity_decode( $_POST['ivole_email_body'] ) ) ) ) {
+ if ( ! empty( $_POST ) && isset( $_POST['ivole_email_body'] ) ) {
+ if ( empty( preg_replace( '#s#isUu', '', html_entity_decode( $_POST['ivole_email_body'] ) ) ) ) {
WC_Admin_Settings::add_error( __( ''Email Body' field cannot be empty', 'customer-reviews-woocommerce' ) );
$_POST['ivole_email_body'] = get_option( 'ivole_email_body' );
}
}
- if( ! empty( $_POST ) && isset( $_POST['ivole_email_body_coupon'] ) ) {
- if( empty( preg_replace( '#s#isUu', '', html_entity_decode( $_POST['ivole_email_body_coupon'] ) ) ) ) {
+ if ( ! empty( $_POST ) && isset( $_POST['ivole_email_body_coupon'] ) ) {
+ if ( empty( preg_replace( '#s#isUu', '', html_entity_decode( $_POST['ivole_email_body_coupon'] ) ) ) ) {
WC_Admin_Settings::add_error( __( ''Email Body' field cannot be empty', 'customer-reviews-woocommerce' ) );
$_POST['ivole_email_body_coupon'] = get_option( 'ivole_email_body_coupon' );
}
}
// validate colors (users sometimes remove # or provide invalid hex color codes)
if ( ! empty( $_POST ) && isset( $_POST['ivole_email_color_bg'] ) ) {
- if( ! preg_match_all( '/#([a-f0-9]{3}){1,2}b/i', $_POST['ivole_email_color_bg'] ) ) {
+ if ( ! preg_match_all( '/#([a-f0-9]{3}){1,2}b/i', $_POST['ivole_email_color_bg'] ) ) {
$_POST['ivole_email_color_bg'] = '#0f9d58';
}
}
if ( ! empty( $_POST ) && isset( $_POST['ivole_email_color_text'] ) ) {
- if( ! preg_match_all( '/#([a-f0-9]{3}){1,2}b/i', $_POST['ivole_email_color_text'] ) ) {
+ if ( ! preg_match_all( '/#([a-f0-9]{3}){1,2}b/i', $_POST['ivole_email_color_text'] ) ) {
$_POST['ivole_email_color_text'] = '#ffffff';
}
}
+ if ( ! empty( $_POST ) && isset( $_POST['ivole_email_qna_color_bg'] ) ) {
+ if ( ! preg_match_all( '/#([a-f0-9]{3}){1,2}b/i', $_POST['ivole_email_qna_color_bg'] ) ) {
+ $_POST['ivole_email_qna_color_bg'] = '#0f9d58';
+ }
+ }
+ if ( ! empty( $_POST ) && isset( $_POST['ivole_email_qna_color_text'] ) ) {
+ if ( ! preg_match_all( '/#([a-f0-9]{3}){1,2}b/i', $_POST['ivole_email_qna_color_text'] ) ) {
+ $_POST['ivole_email_qna_color_text'] = '#ffffff';
+ }
+ }
//
do_action( 'cr_settings_email_save_fields', $_POST );
//
--- a/customer-reviews-woocommerce/includes/settings/class-cr-settings-review-reminder.php
+++ b/customer-reviews-woocommerce/includes/settings/class-cr-settings-review-reminder.php
@@ -891,6 +891,25 @@
* Function to check status of the license and verification of email
*/
public function check_license_email_ajax() {
+ $res = array(
+ 'license' => '',
+ 'email' => 0,
+ 'fromEmail' => '',
+ 'fromName' => '',
+ 'emailFooter' => '',
+ 'dkim' => ''
+ );
+
+ if ( ! current_user_can( apply_filters( 'cr_settings_permissions', 'manage_options' ) ) ) {
+ wp_send_json( $res );
+ wp_die();
+ }
+
+ if ( ! check_ajax_referer( 'cr-settings-ajax', 'nonce', false ) ) {
+ wp_send_json( $res );
+ wp_die();
+ }
+
$license = new CR_License();
$lval = $license->check_license();
@@ -925,7 +944,29 @@
}
public function verify_email_ajax() {
- $email = strval( $_POST['email'] );
+ if ( ! current_user_can( apply_filters( 'cr_settings_permissions', 'manage_options' ) ) ) {
+ wp_send_json(
+ array(
+ 'verification' => 100,
+ 'email' => '',
+ 'message' => __( 'Permission denied', 'customer-reviews-woocommerce' )
+ )
+ );
+ wp_die();
+ }
+
+ if ( ! check_ajax_referer( 'cr-settings-ajax', 'nonce', false ) ) {
+ wp_send_json(
+ array(
+ 'verification' => 100,
+ 'email' => '',
+ 'message' => __( 'Error: nonce expired, please reload the page and try again', 'customer-reviews-woocommerce' )
+ )
+ );
+ wp_die();
+ }
+
+ $email = sanitize_email( wp_unslash( isset( $_POST['email'] ) ? $_POST['email'] : '' ) );
$verify = new CR_Email_Verify();
$vval = $verify->verify_email( $email );
wp_send_json(
@@ -938,7 +979,27 @@
}
public function verify_dkim_ajax() {
- $email = strval( $_POST['email'] );
+ if ( ! current_user_can( apply_filters( 'cr_settings_permissions', 'manage_options' ) ) ) {
+ wp_send_json(
+ array(
+ 'verification' => 100,
+ 'tokens' => array()
+ )
+ );
+ wp_die();
+ }
+
+ if ( ! check_ajax_referer( 'cr-settings-ajax', 'nonce', false ) ) {
+ wp_send_json(
+ array(
+ 'verification' => 100,
+ 'tokens' => array()
+ )
+ );
+ wp_die();
+ }
+
+ $email = sanitize_email( wp_unslash( isset( $_POST['email'] ) ? $_POST['email'] : '' ) );
$verify = new CR_Email_Verify();
$vval = $verify->verify_dkim( $email );
wp_send_json(
--- a/customer-reviews-woocommerce/ivole.php
+++ b/customer-reviews-woocommerce/ivole.php
@@ -3,7 +3,7 @@
Plugin Name: Customer Reviews for WooCommerce
Description: Customer Reviews for WooCommerce plugin helps you get more customer reviews for your shop by sending automated reminders and coupons.
Plugin URI: https://wordpress.org/plugins/customer-reviews-woocommerce/
-Version: 5.115.0
+Version: 5.116.0
Author: CusRev
Author URI: https://www.cusrev.com/business/
Text Domain: customer-reviews-woocommerce
--- a/customer-reviews-woocommerce/templates/qna-email-reply.php
+++ b/customer-reviews-woocommerce/templates/qna-email-reply.php
@@ -20,10 +20,10 @@
<tr>
<td align="center" valign="top">
<!-- Header -->
- <table border="0" cellpadding="0" cellspacing="0" width="100%" id="template_header" style="background-color:#0f9d58;border-radius: 3px 3px 0 0 !important;color:#FFFFFF;border-bottom:0;font-weight:bold;line-height:100%;vertical-align:middle;font-family:Helvetica,Roboto,Arial,sans-serif;">
- <tr>
- <td id="header_wrapper" style="padding:36px 48px;display:block;width:100%;box-sizing:border-box;">
- <h1 style="color:#FFFFFF;line-height:150%;background-color:inherit;"><?php echo $cr_email_heading; ?></h1>
+ <table border="0" cellpadding="0" cellspacing="0" width="100%" id="template_header" style="background-color:<?php echo esc_attr( $cr_email_color_bg ); ?>;border-radius: 3px 3px 0 0 !important;color:<?php echo esc_attr( $cr_email_color_text ); ?>;border-bottom:0;font-weight:bold;line-height:100%;vertical-align:middle;font-family:Helvetica,Roboto,Arial,sans-serif;">
+ <tr>
+ <td id="header_wrapper" style="padding:36px 48px;display:block;width:100%;box-sizing:border-box;">
+ <h1 style="color:<?php echo esc_attr( $cr_email_color_text ); ?>;line-height:150%;background-color:inherit;"><?php echo $cr_email_heading; ?></h1>
</td>
</tr>
</table>
--- a/customer-reviews-woocommerce/uninstall.php
+++ b/customer-reviews-woocommerce/uninstall.php
@@ -44,6 +44,8 @@
'ivole_coupon_email_bcc',
'ivole_email_coupon_color_bg',
'ivole_email_coupon_color_text',
+ 'ivole_email_qna_color_bg',
+ 'ivole_email_qna_color_text',
'ivole_coupon_tiers',
'ivole_coupon_prefix',
'ivole_coupon__discount_type',