Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/smaily-connect/admin/smaily-admin-notices.class.php
+++ b/smaily-connect/admin/smaily-admin-notices.class.php
@@ -97,7 +97,9 @@
}
/**
- * Dismiss an admin notice.
+ * Dismiss an admin notice. Only a notice the plugin registered, and only
+ * by a user who may see it (CON-346): any other id is not stored in the
+ * caller's user meta.
*/
public function dismiss_notice() {
check_ajax_referer( 'smaily_connect_dismiss_notice', 'nonce' );
@@ -108,6 +110,14 @@
}
$notice_id = sanitize_text_field( wp_unslash( $_POST['id'] ) );
+ $notices = Notice_Registry::get_notices();
+ if ( ! is_array( $notices ) || ! isset( $notices[ $notice_id ] ) ) {
+ wp_send_json_error( new WP_Error( 'unknown_notice', 'The notice is not registered.' ), 400 );
+ }
+ if ( ! current_user_can( $notices[ $notice_id ]['capability'] ) ) {
+ wp_send_json_error( new WP_Error( 'forbidden', 'You cannot dismiss this notice.' ), 403 );
+ }
+
Notice_Registry::dismiss_notice( $notice_id );
wp_send_json_success();
--- a/smaily-connect/blocks/newsletter-signup/smaily-integration.class.php
+++ b/smaily-connect/blocks/newsletter-signup/smaily-integration.class.php
@@ -27,6 +27,7 @@
'subscribeButtonBackgroundColor' => '#000',
'subscribeButtonTextColor' => '#fff',
'subscribeButtonWidth' => 'auto',
+ 'subscribeButtonBorderRadius' => 0,
'successMessage' => '',
'errorMessage' => '',
'subdomain' => '',
@@ -50,10 +51,10 @@
--smaily-subscribe-button-width: %s;
--smaily-subscribe-button-border-radius: %spx;
',
- esc_attr( $attributes['subscribeButtonBackgroundColor'] ),
- esc_attr( $attributes['subscribeButtonTextColor'] ),
- esc_attr( $attributes['subscribeButtonWidth'] ),
- esc_attr( $attributes['subscribeButtonBorderRadius'] )
+ esc_attr( self::css_color( $attributes['subscribeButtonBackgroundColor'], $defaults['subscribeButtonBackgroundColor'] ) ),
+ esc_attr( self::css_color( $attributes['subscribeButtonTextColor'], $defaults['subscribeButtonTextColor'] ) ),
+ esc_attr( self::css_width( $attributes['subscribeButtonWidth'] ) ),
+ esc_attr( self::css_radius( $attributes['subscribeButtonBorderRadius'] ) )
),
)
);
@@ -129,4 +130,54 @@
return ob_get_clean();
}
+
+ /**
+ * A button colour as the block's editor saves it, else the default. The
+ * value goes into the wrapper's `style` attribute, and esc_attr() does not
+ * stop CSS: anything but a colour could add declarations (CON-346).
+ * Accepted: what the editor saves — a hex colour (3, 4, 6 or 8 digits,
+ * the custom colour picker) and var(--name) with an optional hex
+ * fallback (the editor's defaults and the theme presets,
+ * `var(--wp--preset--color--slug)`).
+ *
+ * @param mixed $value The saved attribute.
+ * @param string $fallback The colour used when the value is not one.
+ * @return string
+ */
+ private static function css_color( $value, $fallback ) {
+ $value = is_string( $value ) ? trim( $value ) : '';
+ $hex = '#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})';
+ $color = '/^(?:' . $hex . '|var(s*--[a-z0-9_-]+s*(?:,s*' . $hex . 's*)?))$/i';
+
+ return preg_match( $color, $value ) === 1 ? $value : $fallback;
+ }
+
+ /**
+ * The button width: `auto` or a number with an optional unit, else `auto`.
+ *
+ * @param mixed $value The saved attribute.
+ * @return string
+ */
+ private static function css_width( $value ) {
+ $value = is_string( $value ) ? trim( $value ) : '';
+
+ return preg_match( '/^(?:auto|d+(?:.d+)?(?:px|%|em|rem|vw|vh|ch)?)$/', $value ) === 1 ? $value : 'auto';
+ }
+
+ /**
+ * The button corner radius in pixels: a non-negative number, else 0.
+ *
+ * @param mixed $value The saved attribute.
+ * @return string
+ */
+ private static function css_radius( $value ) {
+ if ( ( is_int( $value ) || is_float( $value ) ) && $value >= 0 ) {
+ return (string) $value;
+ }
+ if ( is_string( $value ) && preg_match( '/^d+(?:.d+)?$/', $value ) === 1 ) {
+ return $value;
+ }
+
+ return '0';
+ }
}
--- a/smaily-connect/includes/smaily-helper.class.php
+++ b/smaily-connect/includes/smaily-helper.class.php
@@ -375,20 +375,33 @@
}
/**
- * Get the current URL of the webpage. Defaults to site URL when request URL couldn't be determined.
+ * Get the current URL of the webpage: the store's own address (home_url())
+ * with the request's path and query. Defaults to site URL when the request
+ * URL couldn't be determined.
+ *
+ * The client's Host header is never used (CON-346): this is the default
+ * return address of the newsletter forms, and a forged Host would send
+ * the shopper to another site.
*
* @return string
*/
public static function get_current_url() {
- if ( ! isset( $_SERVER['HTTP_HOST'] ) || ! isset( $_SERVER['REQUEST_URI'] ) ) {
+ if ( ! isset( $_SERVER['REQUEST_URI'] ) ) {
+ return get_site_url();
+ }
+
+ $uri = sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) );
+ $parts = wp_parse_url( $uri );
+ $home = wp_parse_url( home_url() );
+ if ( ! is_array( $parts ) || ! is_array( $home ) || ! isset( $home['scheme'], $home['host'] ) ) {
return get_site_url();
}
- $protocol = is_ssl() ? 'https://' : 'http://';
- $host = sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) );
- $uri = sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) );
+ $origin = $home['scheme'] . '://' . $home['host'] . ( isset( $home['port'] ) ? ':' . $home['port'] : '' );
+ $path = isset( $parts['path'] ) ? '/' . ltrim( $parts['path'], '/' ) : '/';
+ $query = isset( $parts['query'] ) ? '?' . $parts['query'] : '';
- return $protocol . $host . $uri;
+ return $origin . $path . $query;
}
/**
--- a/smaily-connect/integrations/elementor/form-action.class.php
+++ b/smaily-connect/integrations/elementor/form-action.class.php
@@ -137,8 +137,11 @@
// the control-type default that ElementorRepeater::add_control() adds,
// so a new row's value is undefined. The editor JSON-clones the row
// before it renders the title template, which drops the key, and
- // `{{{ smaily_field }}}` then throws a ReferenceError. The row is not
+ // `{{ smaily_field }}` then throws a ReferenceError. The row is not
// added, and the whole Smaily section renders blank after that.
+ // The title uses the escaping `{{ }}`, never the raw-HTML `{{{ }}}`:
+ // the field name is typed by whoever edits the form, and the title
+ // is rendered in every editor's browser.
$widget->add_control(
'smaily_fields',
array(
@@ -160,7 +163,7 @@
),
),
'prevent_empty' => false,
- 'title_field' => '{{{ smaily_field }}}',
+ 'title_field' => '{{ smaily_field }}',
)
);
--- a/smaily-connect/integrations/woocommerce/data-handler.class.php
+++ b/smaily-connect/integrations/woocommerce/data-handler.class.php
@@ -19,11 +19,14 @@
*/
public static function get_products( $category, $limit, $order_by, $order ) {
// Initial query.
+ // The feed is public: a password-protected product is never listed
+ // (CON-345). `has_password` passes through to WP_Query.
$product = array(
- 'status' => 'publish',
- 'limit' => $limit,
- 'orderby' => 'none',
- 'order' => 'DESC',
+ 'status' => 'publish',
+ 'has_password' => false,
+ 'limit' => $limit,
+ 'orderby' => 'none',
+ 'order' => 'DESC',
);
if ( ! empty( $order_by ) ) {
--- a/smaily-connect/integrations/woocommerce/profile-settings.class.php
+++ b/smaily-connect/integrations/woocommerce/profile-settings.class.php
@@ -55,6 +55,8 @@
public function smaily_print_user_frontend_fields() {
$fields = $this->get_fields();
$is_user_logged_in = is_user_logged_in();
+ // Always the shopper's own values: never pick the user from the request (CON-343).
+ $user_id = get_current_user_id();
foreach ( $fields as $key => $field_args ) {
$value = null;
@@ -70,8 +72,7 @@
// Get user information and save in value.
if ( $is_user_logged_in ) {
- $user_id = $this->smaily_get_edit_user_id();
- $value = $this->smaily_get_userdata( $user_id, $key );
+ $value = $this->smaily_get_userdata( $user_id, $key );
}
$value = isset( $field_args['value'] ) ? $field_args['value'] : $value;
@@ -110,11 +111,18 @@
}
/**
- * Add fields to admin area
+ * Add fields to admin area, with the values of the user WordPress opened
+ * the profile screen for (CON-343).
*
+ * @param WP_User $user The user being edited, as `show_user_profile` /
+ * `edit_user_profile` pass it.
* @return void
*/
- public function smaily_print_user_admin_fields() {
+ public function smaily_print_user_admin_fields( $user ) {
+ if ( ! $user instanceof WP_User || ! current_user_can( 'edit_user', $user->ID ) ) {
+ return;
+ }
+
$fields = $this->get_fields();
?>
<h2><?php esc_html_e( 'Additional Information', 'smaily-connect' ); ?></h2>
@@ -125,8 +133,7 @@
continue;
}
- $user_id = $this->smaily_get_edit_user_id();
- $value = $this->smaily_get_userdata( $user_id, $key );
+ $value = $this->smaily_get_userdata( $user->ID, $key );
?>
<tr>
<th>
@@ -243,17 +250,6 @@
}
/**
- * Get currently editing user ID (frontend account/edit profile/edit other user).
- * Nonce field should be verified prior to calling this function.
- *
- * @return int $user_id Current user ID
- */
- public function smaily_get_edit_user_id() {
- // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- int-cast read used only to scope a profile lookup; the form-save path verifies the nonce (see docblock).
- return isset( $_GET['user_id'] ) ? (int) $_GET['user_id'] : get_current_user_id();
- }
-
- /**
* Get user data based on key
*
* @param int $user_id User ID.
--- a/smaily-connect/integrations/woocommerce/rss.class.php
+++ b/smaily-connect/integrations/woocommerce/rss.class.php
@@ -8,6 +8,18 @@
class Rss {
/**
+ * The most products one feed request lists, whatever the address asks
+ * for (CON-345). The feed is public, so an address must not make the
+ * store load its whole catalog.
+ */
+ const MAX_FEED_ITEMS = 100;
+
+ /**
+ * Products listed when the address names no limit (or 0).
+ */
+ const DEFAULT_FEED_ITEMS = 50;
+
+ /**
* Constructor.
*/
public function __construct() {}
@@ -142,7 +154,7 @@
* @return list<array{created_at: string, current_price: float, description: string, discount: float, enclosure_url: string, regular_price: float, title: string, url: string}>
*/
public static function list_rss_feed_items( $category, $limit, $order_by, $order, $tax_rate ) {
- $products = Data_Handler::get_products( $category, $limit, $order_by, $order );
+ $products = Data_Handler::get_products( $category, self::feed_limit( (int) $limit ), $order_by, $order );
$items = array();
foreach ( $products as $prod ) {
$product = function_exists( 'wc_get_product' ) ? wc_get_product( $prod->get_id() ) : new WC_Product( $prod->get_id() );
@@ -177,6 +189,23 @@
}
/**
+ * How many products a feed request lists: 1–100 as asked, none (0)
+ * gives the default 50, and a negative or larger number gives 100.
+ *
+ * @param int $limit The limit the feed address asks for.
+ * @return int
+ */
+ public static function feed_limit( int $limit ): int {
+ if ( $limit === 0 ) {
+ return self::DEFAULT_FEED_ITEMS;
+ }
+ if ( $limit < 0 || $limit > self::MAX_FEED_ITEMS ) {
+ return self::MAX_FEED_ITEMS;
+ }
+ return $limit;
+ }
+
+ /**
* Format discount percentage for display.
*
* @param float $discount
--- a/smaily-connect/public/template/smaily-rss-feed.php
+++ b/smaily-connect/public/template/smaily-rss-feed.php
@@ -17,8 +17,7 @@
$tax_rate = $tax_rate !== '' ? (float) $tax_rate : null;
$currencysymbol = get_woocommerce_currency_symbol();
-// Default to 50 products.
-$limit = $limit === 0 ? 50 : $limit;
+// The default (50) and the maximum (100) are applied in Rss::feed_limit().
$items = Rss::list_rss_feed_items( $category, $limit, $order_by, $rss_order, $tax_rate );
header( 'Content-Type: application/xml' );
--- a/smaily-connect/smaily-connect.php
+++ b/smaily-connect/smaily-connect.php
@@ -13,7 +13,7 @@
* Plugin Name: Smaily Connect
* Plugin URI: https://smaily.com/help/user-manual/smaily-connect-for-wordpress/
* Text Domain: smaily-connect
- * Version: 3.24.0
+ * Version: 3.24.1
*/
// Exit if accessed directly.
@@ -24,13 +24,13 @@
/**
* Current plugin version (PSR-4 callers should prefer SmailyConnectConstants::version()).
*/
-define( 'SMAILY_CONNECT_VERSION', '3.24.0' );
+define( 'SMAILY_CONNECT_VERSION', '3.24.1' );
/**
* Legacy version constant — kept for upstream compatibility (used by older
* classes that still reference it). New code should use SMAILY_CONNECT_VERSION.
*/
-define( 'SMAILY_CONNECT_PLUGIN_VERSION', '3.24.0' );
+define( 'SMAILY_CONNECT_PLUGIN_VERSION', '3.24.1' );
/**
* The name of the plugin.
--- a/smaily-connect/vendor/composer/installed.php
+++ b/smaily-connect/vendor/composer/installed.php
@@ -1,9 +1,9 @@
<?php return array(
'root' => array(
'name' => 'smaily/smaily-wordpress-plugin',
- 'pretty_version' => '3.24.0',
- 'version' => '3.24.0.0',
- 'reference' => '94a45593b9be761347a32cd2178e752bd03c17f2',
+ 'pretty_version' => '3.24.1',
+ 'version' => '3.24.1.0',
+ 'reference' => '9e73615b776adb516dadedabb0e7b3b39d9ca4fb',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
@@ -11,9 +11,9 @@
),
'versions' => array(
'smaily/smaily-wordpress-plugin' => array(
- 'pretty_version' => '3.24.0',
- 'version' => '3.24.0.0',
- 'reference' => '94a45593b9be761347a32cd2178e752bd03c17f2',
+ 'pretty_version' => '3.24.1',
+ 'version' => '3.24.1.0',
+ 'reference' => '9e73615b776adb516dadedabb0e7b3b39d9ca4fb',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),