mailchimp / mc-woocommerce

MailChimp for Woocommerce Integration. Syncs all data (subscriber, customers, orders, products) and enables marketing automation with email campaigns, automations, ads, postcards and more.
https://wordpress.org/plugins/mailchimp-for-woocommerce/
GNU General Public License v2.0
82 stars 66 forks source link

[BUG] esc_html used instead of esc_attr, causing incorrect store name in Mailchimp #1198

Open chvillanuevap opened 1 week ago

chvillanuevap commented 1 week ago

Describe the bug I'm using version 4.2.1, but I have seen the same code in 4.3.1. In 4.2.1, in admin/partials/tab/api-key.php:45, admin/v2/templates/connect-accounts/create-account-page.php:81, and admin/v2/templates/connect-accounts/create-account-popup.php:30, there is the following input field:

<input id="org" name="org" type="hidden" value="<?php echo esc_html( get_bloginfo( 'name' ) ); ?>">

The sanitizing function esc_html should not be used here, because it will convert characters like quotes into HTML entities. For example, my store, The Postman's Knock, is being saved as s:10:"store_name";s:24:"The Postman&#039;s Knock"; in mailchimp_woocommerce in wp_options and displays like this in Mailchimp:

Screenshot 2024-09-04 at 9 46 03 PM

The correct function to use to sanitize attributes like value is esc_attr. This should be changed in all 3 instances of this input field.

If I change the value in my database, will that update in Mailchimp? The GUI does not have an option to change the name.

To Reproduce Steps to reproduce the behavior:

  1. Go to the Connect Account admin page on installation where the input field is located.
  2. Use a store name with an apostrophe.
  3. See how it's stored in the database and displayed on Mailchimp.

Expected behavior The store name should be displayed correctly without HTML entities, using the correct sanitizing function (esc_attr instead of esc_html).

Operating environment (please complete the following information):

Things to verify before submitting a ticket

kjvextras commented 1 week ago

Hi @chvillanuevap - Thanks for reaching out. We will check this out and circle back.

ryanhungate commented 1 week ago

We've started a new branch 4.4 which will address this. Thanks for reporting.