Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: dont html encode ampersands in subject #1686

Merged
merged 3 commits into from
Nov 4, 2024
Merged

Conversation

leogermani
Copy link
Contributor

All Submissions:

Changes proposed in this Pull Request:

Fixes a small issue where ampersands are HTML encoded in the Subject.

Not sure if there's a better way to do it. But it's weird because the only character that is being HTML encoded is the ampersand, so loading a library to html_decode everything looked unnecessary.

How to test the changes in this Pull Request:

  1. In trunk edit a newsletters
  2. add a & to the title and see that $amp; is added to the Subject input in the Newsletter sidebar
  3. Checkout this branch and do the same
  4. See that & is preserved as is

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@leogermani leogermani self-assigned this Oct 30, 2024
@leogermani leogermani requested a review from a team as a code owner October 30, 2024 20:05
Copy link

codecov bot commented Oct 30, 2024

Codecov Report

Attention: Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.

Project coverage is 20.38%. Comparing base (44c1b12) to head (858cb56).
Report is 4 commits behind head on trunk.

Files with missing lines Patch % Lines
...or/class-newspack-newsletters-campaign-monitor.php 0.00% 2 Missing ⚠️
...ign/class-newspack-newsletters-active-campaign.php 0.00% 1 Missing ⚠️
...ct/class-newspack-newsletters-constant-contact.php 0.00% 1 Missing ⚠️
...mailchimp/class-newspack-newsletters-mailchimp.php 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##              trunk    #1686   +/-   ##
=========================================
  Coverage     20.38%   20.38%           
  Complexity     2664     2664           
=========================================
  Files            48       48           
  Lines         10619    10619           
=========================================
  Hits           2165     2165           
  Misses         8454     8454           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@dkoo dkoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leogermani this didn't work for me for some reason—the ampersands were still coming in as & in the the subject text input when editing the post title field, and when synced to the ESP the subject still contained &. I think WP converts certain characters into HTML entities when the strings are saved into the DB.

Here's what I had to do to fix the issue: #1687

This doesn't try to save the title with unescaped characters, it just displays the unescaped string in the sidebar field, and then decodes the HTML entities in the sync payload that gets sent to the ESP. Let me know what you think!

@leogermani
Copy link
Contributor Author

@dkoo Your PR looks much more robust! Feel free to take it over!

fix: decode HTML entities in both editor JS and sync payloads
@dkoo
Copy link
Contributor

dkoo commented Oct 31, 2024

@leogermani I've merged #1687 into this PR. Paging @Automattic/newspack-product for another review!

@dkoo dkoo requested a review from a team October 31, 2024 20:48
@dkoo dkoo self-assigned this Oct 31, 2024
@leogermani
Copy link
Contributor Author

Works for me!

Copy link
Contributor

@dkoo dkoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥸 PR approved, @dkoo!

@dkoo dkoo merged commit f178b23 into trunk Nov 4, 2024
9 checks passed
@dkoo dkoo deleted the fix/amperstands-subject branch November 4, 2024 21:19
@github-actions github-actions bot added [Status] Approved Ready to merge and removed [Status] Needs Review labels Nov 4, 2024
matticbot pushed a commit that referenced this pull request Nov 6, 2024
# [3.4.0-alpha.1](v3.3.2...v3.4.0-alpha.1) (2024-11-06)

### Bug Fixes

* avoid race condition between post-save sync & test ([#1679](#1679)) ([7bde119](7bde119))
* avoid Redux usage and related errors in non-newsletter email editors ([#1688](#1688)) ([d3f1f37](d3f1f37))
* dont html encode ampersands in subject ([#1686](#1686)) ([f178b23](f178b23))
* **mailchimp:** avoid duplicate audiences in Mailchimp UIs ([#1685](#1685)) ([44c1b12](44c1b12))
* move Preview, Send buttons to match Publish button location ([#1689](#1689)) ([72897f2](72897f2))
* preview & send buttons on WP 6.7 ([49450d3](49450d3))

### Features

* display list remote name on settings page ([#1672](#1672)) ([562d396](562d396))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 3.4.0-alpha.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

matticbot pushed a commit that referenced this pull request Nov 11, 2024
# [3.4.0](v3.3.3...v3.4.0) (2024-11-11)

### Bug Fixes

* avoid double notice components ([#1703](#1703)) ([b8e9130](b8e9130))
* avoid race condition between post-save sync & test ([#1679](#1679)) ([7bde119](7bde119))
* avoid Redux usage and related errors in non-newsletter email editors ([#1688](#1688)) ([d3f1f37](d3f1f37))
* correct button stacking on sent newsletters ([#1695](#1695)) ([4e2688e](4e2688e))
* dont html encode ampersands in subject ([#1686](#1686)) ([f178b23](f178b23))
* **mailchimp:** avoid duplicate audiences in Mailchimp UIs ([#1685](#1685)) ([44c1b12](44c1b12))
* move Preview, Send buttons to match Publish button location ([#1689](#1689)) ([72897f2](72897f2))
* preview & send buttons on WP 6.7 ([49450d3](49450d3))
* remove behavior to hide post title in newsletter editor ([#1701](#1701)) ([8a15cf5](8a15cf5))

### Features

* display list remote name on settings page ([#1672](#1672)) ([562d396](562d396))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants