Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/smart-wishlist-for-more-convert/includes/class-wlfmc-admin.php
+++ b/smart-wishlist-for-more-convert/includes/class-wlfmc-admin.php
@@ -5,7 +5,7 @@
* @author MoreConvert
* @package Smart Wishlist For More Convert
*
- * @version 1.9.19
+ * @version 1.9.20
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -30,7 +30,7 @@
*
* @var string
*/
- public $rollback_version = '1.9.18';
+ public $rollback_version = '1.9.19';
/**
* Minimum pro version
--- a/smart-wishlist-for-more-convert/includes/class-wlfmc-ajax-handler.php
+++ b/smart-wishlist-for-more-convert/includes/class-wlfmc-ajax-handler.php
@@ -755,6 +755,9 @@
* @version 1.3.3
*/
public static function add_to_wishlist() {
+
+ check_ajax_referer( 'wlfmc_add_to_list_nonce', 'nonce' );
+
$result = false;
try {
$result = WLFMC()->add();
--- a/smart-wishlist-for-more-convert/includes/class-wlfmc-shortcode.php
+++ b/smart-wishlist-for-more-convert/includes/class-wlfmc-shortcode.php
@@ -272,7 +272,15 @@
if ( defined( 'MC_WLFMC_PREMIUM' ) ) {
$show_total_price = $show_total_price && 0 < $wishlist->count_items();
$enable_drag_n_drop = $enable_drag_n_drop && 1 < $wishlist->count_items() && $wishlist->current_user_can( 'drag_n_drop' ) && ! $no_interactions;
- $pagination = ! $enable_drag_n_drop && $pagination;
+ /**
+ * Filter whether Drag & Drop should disable pagination.
+ *
+ * @param bool $disable_pagination Default is false (pagination stays active).
+ */
+ $disable_pagination_on_drag_drop = apply_filters( 'wlfmc_disable_pagination_on_drag_drop', false );
+ if ( $disable_pagination_on_drag_drop ) {
+ $pagination = ! $enable_drag_n_drop && $pagination;
+ }
}
// sets current page, number of pages and element offset.
--- a/smart-wishlist-for-more-convert/includes/class-wlfmc.php
+++ b/smart-wishlist-for-more-convert/includes/class-wlfmc.php
@@ -4,7 +4,7 @@
*
* @author MoreConvert
* @package Smart Wishlist For More Convert
- * @version 1.9.19
+ * @version 1.9.20
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -27,7 +27,7 @@
*
* @var string
*/
- public $version = '1.9.19';
+ public $version = '1.9.20';
/**
* Plugin database version
--- a/smart-wishlist-for-more-convert/includes/functions.php
+++ b/smart-wishlist-for-more-convert/includes/functions.php
@@ -1548,11 +1548,49 @@
function wlfmc_process_product_data( $product_type, $atts, $prod_id, $quantity ) {
$variations = array();
if ( in_array( $product_type, array( 'variable', 'variation', 'variable-subscription' ), true ) ) {
+ /*
foreach ( $_REQUEST as $key => $value ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( 'attribute_' !== substr( $key, 0, 10 ) || '' === $value ) {
continue;
}
$variations['attributes'][ sanitize_title( wp_unslash( $key ) ) ] = wp_unslash( $value );
+ }*/
+
+ $product = wc_get_product( $prod_id );
+ if ( $product ) {
+ if ( $product->is_type( 'variation' ) ) {
+ $parent_id = $product->get_parent_id();
+ $parent_product = wc_get_product( $parent_id );
+ $attributes = $parent_product ? $parent_product->get_attributes() : array();
+ } else {
+ $attributes = $product->get_attributes();
+ }
+
+ foreach ( $_REQUEST as $key => $value ) {
+ if ( 'attribute_' !== substr( $key, 0, 10 ) || '' === $value ) {
+ continue;
+ }
+
+ $attribute_name = str_replace( 'attribute_', '', sanitize_title( $key ) );
+
+ if ( isset( $attributes[ $attribute_name ] ) ) {
+ $attribute = $attributes[ $attribute_name ];
+
+ if ( $attribute['is_variation'] ) {
+ if ( $attribute['is_taxonomy'] ) {
+ $sanitized_value = sanitize_title( wp_unslash( $value ) );
+ } else {
+ $sanitized_value = html_entity_decode( wc_clean( wp_unslash( $value ) ), ENT_QUOTES, get_bloginfo( 'charset' ) );
+ }
+
+ if ( ! empty( $sanitized_value ) || '0' === $sanitized_value ) {
+ $variations['attributes'][ sanitize_title( $key ) ] = $sanitized_value;
+ }
+ }
+ } else {
+ $variations['attributes'][ sanitize_title( wp_unslash( $key ) ) ] = sanitize_title( wp_unslash( $value ) );
+ }
+ }
}
}
--- a/smart-wishlist-for-more-convert/smart-wishlist-for-more-convert.php
+++ b/smart-wishlist-for-more-convert/smart-wishlist-for-more-convert.php
@@ -3,7 +3,7 @@
* Plugin Name: MoreConvert Wishlist for WooCommerce
* Plugin URI: https://moreconvert.com/smart-wishlist-for-more-convert
* Description: With the MoreConvert Wishlist for WooCommerce plugin, your website users can add their favorite products to the wishlist. Then you can persuade them to buy products on their wishlist through the magic of our Marketing Toolkits.
- * Version: 1.9.19
+ * Version: 1.9.20
* Author: MoreConvert
* Author URI: https://moreconvert.com
* Text Domain: wc-wlfmc-wishlist
@@ -14,7 +14,7 @@
*
* @author MoreConvert
* @package Smart Wishlist For More Convert
- * @version 1.9.19
+ * @version 1.9.20
*/
/**
--- a/smart-wishlist-for-more-convert/templates/mc-add-to-wishlist.php
+++ b/smart-wishlist-for-more-convert/templates/mc-add-to-wishlist.php
@@ -81,6 +81,7 @@
class="<?php echo esc_attr( $classes_add ); ?>"
data-popup-id="add_to_list_popup"
data-exclude-default="false"
+ data-nonce="<?php echo esc_attr( wp_create_nonce( 'wlfmc_add_to_list_nonce' ) ); ?>"
data-product-id="<?php echo esc_attr( $product_id ); ?>"
data-product-type="<?php echo esc_attr( $product_type ); ?>"
data-parent-product-id="<?php echo esc_attr( $parent_product_id ); ?>">
@@ -129,6 +130,7 @@
<a
href="#" rel="nofollow"
<?php echo ( '' !== $button_label_add ) ? '' : 'aria-label="' . esc_attr_x( 'Add to wishlist', 'aria-label text', 'wc-wlfmc-wishlist' ) . '"'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
+ data-nonce="<?php echo esc_attr( wp_create_nonce( 'wlfmc_add_to_list_nonce' ) ); ?>"
data-product-id="<?php echo esc_attr( $product_id ); ?>"
data-product-type="<?php echo esc_attr( $product_type ); ?>"
data-parent-product-id="<?php echo esc_attr( $parent_product_id ); ?>"
--- a/smart-wishlist-for-more-convert/templates/mc-wishlist-pdf.php
+++ b/smart-wishlist-for-more-convert/templates/mc-wishlist-pdf.php
@@ -237,7 +237,7 @@
/**
* @var $product WC_Product_Variation
*/
- echo wc_get_formatted_variation( ! empty( $meta['attributes'] ) ? array_combine( array_map( 'rawurldecode', array_keys( $meta['attributes'] ) ), $meta['attributes'] ) : $product ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ echo wp_kses_post( wc_get_formatted_variation( ! empty( $meta['attributes'] ) ? array_combine( array_map( 'rawurldecode', array_keys( $meta['attributes'] ) ), $meta['attributes'] ) : $product ) );
?>
</td>
--- a/smart-wishlist-for-more-convert/templates/mc-wishlist-view.php
+++ b/smart-wishlist-for-more-convert/templates/mc-wishlist-view.php
@@ -292,7 +292,7 @@
/**
* @var $product WC_Product_Variation
*/
- echo wc_get_formatted_variation( ! empty( $meta['attributes'] ) ? array_combine( array_map( 'rawurldecode', array_keys( $meta['attributes'] ) ), $meta['attributes'] ) : $product ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ echo wp_kses_post( wc_get_formatted_variation( ! empty( $meta['attributes'] ) ? array_combine( array_map( 'rawurldecode', array_keys( $meta['attributes'] ) ), $meta['attributes'] ) : $product ) );
?>
</div>
@@ -355,7 +355,7 @@
<!-- Add to cart button -->
- <?php if ( apply_filters( 'wlfmc_product_add_to_cart_button', true, $item, $product, $cart_item ) ) : // ! empty( $meta ) ?>
+ <?php if ( apply_filters( 'wlfmc_product_add_to_cart_button', true, $item, $product, $cart_item ) ) : ?>
<?php
$add_to_cart_url = wp_nonce_url(
@@ -376,8 +376,8 @@
wc_clear_notices();
}
}
- $add_to_cart_text = apply_filters( 'wlfmc_read_more_text', __( 'Read more', 'woocommerce' ), $product, $passed_validation );
- $select_options_text = apply_filters( 'wlfmc_select_options_text', __( 'Select options', 'woocommerce' ), $product, $passed_validation );
+ $add_to_cart_text = apply_filters( 'wlfmc_read_more_text', __( 'Read more', 'wc-wlfmc-wishlist' ), $product, $passed_validation );
+ $select_options_text = apply_filters( 'wlfmc_select_options_text', __( 'Select options', 'wc-wlfmc-wishlist' ), $product, $passed_validation );
switch ( $product->get_type() ) {
case 'external':
$can_add_with_ajax = false;
@@ -427,25 +427,27 @@
$meta
);
$button_class = ' add_to_cart_button button ' . ( $can_add_with_ajax && 'yes' === get_option( 'woocommerce_enable_ajax_add_to_cart' ) ? 'wlfmc_ajax_add_to_cart' : '' );
- echo apply_filters(
- 'wlfmc_product_with_meta_add_to_cart_link',
- sprintf(
- '<a href="%s" data-item_id="%d" data-wishlist_id="%d" data-product_id="%d" data-quantity="%s" class="%s" data-nonce="%s" %s >%s</a>',
- esc_url( $add_to_cart_url ),
- esc_attr( $item->get_id() ),
- esc_attr( $wishlist_id ),
- esc_attr( $product->get_id() ),
- esc_attr( $item->get_quantity() ),
- esc_attr( $button_class ),
- esc_attr( wp_create_nonce( 'wlfmc_add_to_cart_from_wishlist' ) ),
- ! empty( $button_attributes ) ? wc_implode_html_attributes( $button_attributes ) : '',
- esc_html( $add_to_cart_text )
- ),
- $product,
- $passed_validation,
- $item,
- $meta
- );// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ echo wp_kses_post(
+ apply_filters(
+ 'wlfmc_product_with_meta_add_to_cart_link',
+ sprintf(
+ '<a href="%s" data-item_id="%d" data-wishlist_id="%d" data-product_id="%d" data-quantity="%s" class="%s" data-nonce="%s" %s >%s</a>',
+ esc_url( $add_to_cart_url ),
+ esc_attr( $item->get_id() ),
+ esc_attr( $wishlist_id ),
+ esc_attr( $product->get_id() ),
+ esc_attr( $item->get_quantity() ),
+ esc_attr( $button_class ),
+ esc_attr( wp_create_nonce( 'wlfmc_add_to_cart_from_wishlist' ) ),
+ ! empty( $button_attributes ) ? wc_implode_html_attributes( $button_attributes ) : '',
+ esc_html( $add_to_cart_text )
+ ),
+ $product,
+ $passed_validation,
+ $item,
+ $meta
+ )
+ );
?>
<?php elseif ( has_action( 'wlfmc_table_product_' . $product->get_type() . '_add_to_cart_button' ) ) : ?>
<?php do_action( 'wlfmc_table_product_' . $product->get_type() . '_add_to_cart_button', $item, $wishlist, $product, $cart_item, $permalink ); ?>
@@ -487,7 +489,7 @@
echo wp_kses_post( apply_filters( 'wlfmc_no_access_image', '<img class="empty-image" src="' . esc_url( MC_WLFMC_URL ) . 'assets/frontend/images/access-denied.svg" width="296" height="215">', $atts ) );
echo wp_kses_post( apply_filters( 'wlfmc_no_access_title', '' !== $no_access_title ? '<h3 class="empty-title">' . $no_access_title . '</h3>' : '', $atts ) );
echo do_shortcode( apply_filters( 'wlfmc_no_access_message', '' !== $no_access_content ? '<div class="empty-content">' . $no_access_content . '</div>' : '', $atts ) );
- echo wp_kses_post( apply_filters( 'wlfmc_no_access_button', '<a href="' . esc_url( wc_get_page_permalink( 'shop' ) ) . '" class="wc-forward button empty-button">' . esc_html__( 'Go to shop', 'woocommerce' ) . '</a>', $atts ) );
+ echo wp_kses_post( apply_filters( 'wlfmc_no_access_button', '<a href="' . esc_url( wc_get_page_permalink( 'shop' ) ) . '" class="wc-forward button empty-button">' . esc_html__( 'Go to shop', 'wc-wlfmc-wishlist' ) . '</a>', $atts ) );
?>
</td>
</tr>
@@ -498,7 +500,7 @@
echo wp_kses_post( apply_filters( 'wlfmc_no_product_in_wishlist_image', '<img class="empty-image" src="' . esc_url( MC_WLFMC_URL ) . 'assets/frontend/images/empty-wishlist.svg" width="400" height="216">', $wishlist, $atts ) );
echo wp_kses_post( apply_filters( 'wlfmc_no_product_in_wishlist_title', '' !== $empty_wishlist_title ? '<h3 class="empty-title">' . $empty_wishlist_title . '</h3>' : '', $wishlist, $atts ) );
echo do_shortcode( apply_filters( 'wlfmc_no_product_in_wishlist_message', '' !== $empty_wishlist_content ? '<div class="empty-content">' . $empty_wishlist_content . '</div>' : '', $wishlist, $atts ) );
- echo wp_kses_post( apply_filters( 'wlfmc_no_product_in_wishlist_button', '<a href="' . esc_url( wc_get_page_permalink( 'shop' ) ) . '" class="wc-forward button empty-button">' . esc_html__( 'Go to shop', 'woocommerce' ) . '</a>', $wishlist, $atts ) );
+ echo wp_kses_post( apply_filters( 'wlfmc_no_product_in_wishlist_button', '<a href="' . esc_url( wc_get_page_permalink( 'shop' ) ) . '" class="wc-forward button empty-button">' . esc_html__( 'Go to shop', 'wc-wlfmc-wishlist' ) . '</a>', $wishlist, $atts ) );
?>
</td>
</tr>