Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Decode HTML entities when formatting Store API error messages #5870

Merged
merged 6 commits into from
Apr 11, 2022

Conversation

manospsyx
Copy link

Fixes #5869

Accessibility

Other Checks

  • I've updated this doc for any feature flags or experimental interfaces implemented in this pull request.
  • I tagged two reviewers because this PR makes queries to the database or I think it might have some security impact.

Screenshots

See #5869

Testing

Automated Tests

  • Changes in this PR are covered by Automated Tests.
    • Unit tests
    • E2E tests

Manual Testing

How to test the changes in this Pull Request:

  1. Add a callback to the wooocommerce_store_api_validate_cart_item action and throw a RouteException that includes HTML entities.
  2. Open the Cart Block.
  3. You should see a notice with the message you added to your Exception.
  4. Go to the Checkout Block.
  5. Attempt to place the order.
  6. You should see the same message, with entities decoded.

User Facing Testing

These are steps for user testing (where "user" is someone interacting with this change that is not editing any code).

  • Same as above, or
  • See steps below.

Performance Impact

Changelog

Decode HTML entities when formatting Store API error messages.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 16, 2022

Size Change: -174 B (0%)

Total Size: 863 kB

Filename Size Change
build/active-filters-frontend.js 6.28 kB +6 B (0%)
build/active-filters.js 6.96 kB +19 B (0%)
build/all-products-frontend.js 18.6 kB -14 B (0%)
build/all-products.js 34 kB +29 B (0%)
build/all-reviews.js 8.05 kB +25 B (0%)
build/atomic-block-components/add-to-cart--atomic-block-components/button--atomic-block-components/image---a7e2bb9b.js 2.64 kB -10 B (0%)
build/atomic-block-components/add-to-cart.js 7.49 kB -2 B (0%)
build/atomic-block-components/button--atomic-block-components/category-list--atomic-block-components/imag--f11cdc7a.js 501 B +3 B (+1%)
build/atomic-block-components/button-frontend.js 2.08 kB +2 B (0%)
build/atomic-block-components/button.js 2.3 kB -2 B (0%)
build/atomic-block-components/category-list-frontend.js 922 B +2 B (0%)
build/atomic-block-components/category-list.js 500 B -1 B (0%)
build/atomic-block-components/image-frontend.js 1.86 kB +2 B (0%)
build/atomic-block-components/image.js 1.08 kB -1 B (0%)
build/atomic-block-components/price-frontend.js 1.95 kB +13 B (+1%)
build/atomic-block-components/price.js 1.51 kB +2 B (0%)
build/atomic-block-components/rating-frontend.js 1.14 kB +4 B (0%)
build/atomic-block-components/rating.js 717 B -1 B (0%)
build/atomic-block-components/sale-badge-frontend.js 1.1 kB +3 B (0%)
build/atomic-block-components/sale-badge.js 685 B +2 B (0%)
build/atomic-block-components/stock-indicator-frontend.js 1.04 kB +4 B (0%)
build/atomic-block-components/summary-frontend.js 1.34 kB +3 B (0%)
build/atomic-block-components/tag-list-frontend.js 924 B +3 B (0%)
build/atomic-block-components/tag-list.js 498 B -1 B (0%)
build/atomic-block-components/title-frontend.js 1.31 kB -2 B (0%)
build/atomic-block-components/title.js 934 B +2 B (0%)
build/attribute-filter-frontend.js 16.8 kB -5 B (0%)
build/attribute-filter.js 13.1 kB +43 B (0%)
build/blocks-checkout.js 17.4 kB +167 B (+1%)
build/cart-blocks/empty-cart-frontend.js 346 B -1 B (0%)
build/cart-blocks/express-payment-frontend.js 5.2 kB +16 B (0%)
build/cart-blocks/filled-cart-frontend.js 768 B +1 B (0%)
build/cart-blocks/line-items-frontend.js 5.5 kB +6 B (0%)
build/cart-blocks/order-summary-frontend.js 8.88 kB +2 B (0%)
build/cart-frontend.js 45.3 kB +137 B (0%)
build/cart.js 43.6 kB +105 B (0%)
build/checkout-blocks/billing-address--checkout-blocks/shipping-address-frontend.js 4.13 kB +1 B (0%)
build/checkout-blocks/contact-information-frontend.js 2.84 kB -1 B (0%)
build/checkout-blocks/express-payment-frontend.js 5.5 kB +17 B (0%)
build/checkout-blocks/order-note-frontend.js 1.13 kB +2 B (0%)
build/checkout-blocks/order-summary-frontend.js 11.3 kB -2 B (0%)
build/checkout-blocks/payment-frontend.js 7.78 kB +18 B (0%)
build/checkout-blocks/shipping-methods-frontend.js 4.73 kB -3 B (0%)
build/checkout-blocks/terms-frontend.js 1.22 kB -1 B (0%)
build/checkout-frontend.js 47.5 kB +139 B (0%)
build/checkout.js 44.8 kB +79 B (0%)
build/featured-category.js 8.64 kB +18 B (0%)
build/featured-product.js 9.74 kB +12 B (0%)
build/handpicked-products.js 7.12 kB +19 B (0%)
build/legacy-template.js 2.19 kB +4 B (0%)
build/mini-cart-component-frontend.js 16 kB -10 B (0%)
build/mini-cart-contents-block/footer--mini-cart-contents-block/products-table-frontend.js 5.32 kB -2 B (0%)
build/mini-cart-contents-block/footer-frontend.js 5.64 kB -634 B (-10%) 👏
build/mini-cart-contents-block/products-table-frontend.js 5.34 kB +4 B (0%)
build/mini-cart-contents.js 23.5 kB -719 B (-3%)
build/mini-cart-frontend.js 1.72 kB +2 B (0%)
build/mini-cart.js 6.39 kB +2 B (0%)
build/price-filter-frontend.js 12.5 kB -3 B (0%)
build/price-filter.js 8.5 kB +25 B (0%)
build/product-best-sellers.js 7.4 kB +26 B (0%)
build/product-categories.js 3.17 kB -4 B (0%)
build/product-category.js 8.51 kB +20 B (0%)
build/product-new.js 7.69 kB +25 B (0%)
build/product-on-sale.js 8.01 kB +20 B (0%)
build/product-search.js 2.19 kB +1 B (0%)
build/product-tag.js 7.82 kB +7 B (0%)
build/product-top-rated.js 7.92 kB +20 B (0%)
build/products-by-attribute.js 8.41 kB +21 B (0%)
build/reviews-by-category.js 11.5 kB +27 B (0%)
build/reviews-by-product.js 12.6 kB +16 B (0%)
build/reviews-frontend.js 7.37 kB +25 B (0%)
build/single-product-frontend.js 22 kB -9 B (0%)
build/single-product.js 10 kB +6 B (0%)
build/stock-filter-frontend.js 6.5 kB +3 B (0%)
build/stock-filter.js 6.57 kB +10 B (0%)
build/vendors--atomic-block-components/add-to-cart--cart-blocks/order-summary--checkout-blocks/billing-ad--c5eb4dcd-frontend.js 19 kB +1 B (0%)
build/vendors--mini-cart-contents-block/footer--mini-cart-contents-block/products-table-frontend.js 7.71 kB -1 B (0%)
build/wc-blocks-data.js 9.87 kB +91 B (+1%)
build/wc-blocks-vendors.js 69.4 kB -6 B (0%)
build/wc-blocks.js 2.62 kB -1 B (0%)
ℹ️ View Unchanged
Filename Size
build/atomic-block-components/add-to-cart--atomic-block-components/button--atomic-block-components/catego--90468e1a.js 223 B
build/atomic-block-components/add-to-cart-frontend.js 7.01 kB
build/atomic-block-components/sku-frontend.js 385 B
build/atomic-block-components/sku.js 386 B
build/atomic-block-components/stock-indicator.js 624 B
build/atomic-block-components/summary.js 923 B
build/cart-blocks/accepted-payment-methods-frontend.js 1.14 kB
build/cart-blocks/checkout-button-frontend.js 1.15 kB
build/cart-blocks/items-frontend.js 299 B
build/cart-blocks/totals-frontend.js 320 B
build/checkout-blocks/actions-frontend.js 1.41 kB
build/checkout-blocks/billing-address-frontend.js 891 B
build/checkout-blocks/fields-frontend.js 344 B
build/checkout-blocks/shipping-address-frontend.js 997 B
build/checkout-blocks/totals-frontend.js 323 B
build/mini-cart-contents-block/empty-cart-frontend.js 363 B
build/mini-cart-contents-block/filled-cart-frontend.js 222 B
build/mini-cart-contents-block/items-frontend.js 206 B
build/mini-cart-contents-block/shopping-button-frontend.js 260 B
build/mini-cart-contents-block/title-frontend.js 348 B
build/price-format.js 1.19 kB
build/vendors--atomic-block-components/add-to-cart-frontend.js 7.51 kB
build/vendors--atomic-block-components/price--cart-blocks/line-items--cart-blocks/order-summary--checkout--194c50bf-frontend.js 5.26 kB
build/vendors--cart-blocks/line-items--checkout-blocks/order-summary--mini-cart-contents-block/products-table-frontend.js 3.14 kB
build/vendors--cart-blocks/order-summary--checkout-blocks/billing-address--checkout-blocks/order-summary---eb4d2cec-frontend.js 4.74 kB
build/wc-blocks-editor-style-rtl.css 4.84 kB
build/wc-blocks-editor-style.css 4.84 kB
build/wc-blocks-google-analytics.js 1.56 kB
build/wc-blocks-middleware.js 953 B
build/wc-blocks-registry.js 2.7 kB
build/wc-blocks-shared-context.js 1.52 kB
build/wc-blocks-shared-hocs.js 1.14 kB
build/wc-blocks-style-rtl.css 22.2 kB
build/wc-blocks-style.css 22.2 kB
build/wc-blocks-vendors-style-rtl.css 1.28 kB
build/wc-blocks-vendors-style.css 1.28 kB
build/wc-payment-method-bacs.js 816 B
build/wc-payment-method-cheque.js 811 B
build/wc-payment-method-cod.js 909 B
build/wc-payment-method-paypal.js 837 B
build/wc-settings.js 2.61 kB

compressed-size-action

@github-actions
Copy link
Contributor

Script Dependencies Report

The compare-assets action has detected some changed script dependencies between this branch and trunk. Please review and confirm the following are correct before merging.

Script Handle Added Removed
all-reviews.js wp-html-entities ⚠️

This comment was automatically generated by the ./github/compare-assets action.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2022

Script Dependencies Report

The compare-assets action has detected some changed script dependencies between this branch and trunk. Please review and confirm the following are correct before merging.

Script Handle Added Removed
all-reviews.js wp-html-entities ⚠️

This comment was automatically generated by the ./github/compare-assets action.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2022

Script Dependencies Report

The compare-assets action has detected some changed script dependencies between this branch and trunk. Please review and confirm the following are correct before merging.

Script Handle Added Removed
all-reviews.js wp-html-entities ⚠️

This comment was automatically generated by the ./github/compare-assets action.

@@ -50,7 +51,7 @@ const StoreNoticesContainer = ( { className, notices, removeNotice } ) => {
}
} }
>
{ props.content }
{ decodeEntities( props.content ) }
Copy link
Contributor

Choose a reason for hiding this comment

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

Hey @manospsyx - I discussed briefly with @xristos3490 and he suggested using decodeEntities in one place (here - the store notices container) rather than everywhere else we call createNotice

What do you think?

I tested it locally and it works as expected (with decodeEntities in assets/js/base/utils/errors.js removed). If you agree, we can revert errors.js and just keep the change in the container.

Copy link
Author

Choose a reason for hiding this comment

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

I remember there's at least one instance where decodeEntities is used outside -- I wasn't sure if that's intentional. I agree with Chris, but let's make sure that we're not double-decoding in other places. Can you check usage of decodeEntities in other locations to make sure?

Copy link
Contributor

Choose a reason for hiding this comment

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

As discussed with @senadir over slack

My personal preference is to not call something unless needed seeing that you can't opt out of it in a clean way, I think decoding all server returned stings makes more sense than decoding at the createNotice level.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2022

Script Dependencies Report

The compare-assets action has detected some changed script dependencies between this branch and trunk. Please review and confirm the following are correct before merging.

Script Handle Added Removed
all-reviews.js wp-html-entities ⚠️

This comment was automatically generated by the ./github/compare-assets action.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2022

Script Dependencies Report

The compare-assets action has detected some changed script dependencies between this branch and trunk. Please review and confirm the following are correct before merging.

Script Handle Added Removed
all-reviews.js wp-html-entities ⚠️

This comment was automatically generated by the ./github/compare-assets action.

@PanosSynetos PanosSynetos requested a review from senadir March 8, 2022 08:52
@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2022

Script Dependencies Report

The compare-assets action has detected some changed script dependencies between this branch and trunk. Please review and confirm the following are correct before merging.

Script Handle Added Removed
all-reviews.js wp-html-entities ⚠️

This comment was automatically generated by the ./github/compare-assets action.

@PanosSynetos PanosSynetos self-assigned this Mar 8, 2022
Copy link
Member

@senadir senadir left a comment

Choose a reason for hiding this comment

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

:shipit:

@github-actions github-actions bot added this to the 7.3.0 milestone Mar 11, 2022
@tjcafferkey tjcafferkey modified the milestones: 7.3.0, 7.4.0 Mar 28, 2022
@manospsyx manospsyx merged commit 7268e7b into trunk Apr 11, 2022
@manospsyx manospsyx deleted the fix/issue-5869 branch April 11, 2022 12:11
@tarhi-saad tarhi-saad added focus: blocks Specific work involving or impacting how blocks behave. type: bug The issue/PR concerns a confirmed bug. block: cart Issues related to the cart block. block: checkout Issues related to the checkout block. labels Apr 11, 2022
tarhi-saad added a commit that referenced this pull request Apr 13, 2022
Remove #5870 testing notes because they can't be tested as a user
tarhi-saad added a commit that referenced this pull request Apr 14, 2022
* Empty commit for release pull request

* Add Changelog to readme.txt

* Update WC tested and required versions

* Add testing notes

* Register missing C&C inner blocks and update fallback template for older C& C versions (#6195)

* Register missing C & C inner blocks and update fallback template for older C & C versions

This will fix the issues with missing order summary inner blocks: Coupons (both in C & C blocks) and the Cart header. The issue was happening because, for example, for Cart the coupons were registred on the on frontend, but it just wasn't forced in the attributes. Because it also wasn't added to the PHP fallback layout, the render function didn't include it. For the Checkout block the coupons inner block wasn't registered at all.

* Revert changes to Checkout.php, we don't need to test for inner blocks

* Revert "Revert changes to Checkout.php, we don't need to test for inner blocks"

This reverts commit fc39535.

* Fix the returned template for older Checkout block iterations

* Fix Cart and Checkout templates to accommodate the Summary order inner blocks

* Hide coupon form div from inner blocks if coubons are not enabled

* Fix checkout coupon tests in checkout

They have been written for logged in user

* Fix Order Summary Heading inner block's default text

* Update comments with better wording

* Revert "Hide coupon form div from inner blocks if coubons are not enabled"

This reverts commit ab09021.

(cherry picked from commit 40180ae)

* Update the zip file link

* Update testing instructions

* Remove experimental build related PR from testing notes

* Fix/order summary sidebar css (#6231)

* Add box sizing to Totals item

* Add some unit tests for Order summary blocks

* Fix Proceed to checkout button size

(cherry picked from commit 669aee7)

* Update the WC required/tested versions

* Mini Cart Contents: Use block pattern to make the empty cart message translatable (#6248)

* try: use block pattern to make empty cart message translatable

* Update src/BlockTypes/MiniCart.php

Co-authored-by: Albert Juhé Lluveras <[email protected]>

* rename function

Co-authored-by: Albert Juhé Lluveras <[email protected]>
Co-authored-by: Luigi <[email protected]>
(cherry picked from commit cfe73f1)

* Update the release's ZIP file

* Update testing notes

In #6065, for Cart only Order Summary Heading & Coupon form can
be removed, and for Checkout only the Coupon form.

* Update the testing notes

Remove #5870 testing notes because they can't be tested as a user

* Update Testing notes

Add screenshots to the #5967 testing notes

* Remove #6166 testing instructions

We reverted this PR

* Revert (#6166) (#6253)

Revert "Prevent Featured Product block from breaking when product is out of stock + hidden
from catalog (#6166)"

This reverts commit 3c0e0af

(cherry picked from commit 908526e)

* Bumping version strings to new version.

Co-authored-by: github-actions <[email protected]>
Co-authored-by: Saad Tarhi <[email protected]>
Co-authored-by: Raluca Stan <[email protected]>
Co-authored-by: Luigi Teschio <[email protected]>
Co-authored-by: Tung Du <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
block: cart Issues related to the cart block. block: checkout Issues related to the checkout block. focus: blocks Specific work involving or impacting how blocks behave. type: bug The issue/PR concerns a confirmed bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HTML entities not decoded when handling failed order payment responses
5 participants