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

Commit cd2f555

Browse files
committed
cherrypick fix for product title in review blocks (#1117)
1 parent 81ca7ff commit cd2f555

File tree

1 file changed

+18
-3
lines changed
  • assets/js/base/components/review-list-item

1 file changed

+18
-3
lines changed

assets/js/base/components/review-list-item/index.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,15 @@ function getReviewContent( review ) {
5555
function getReviewProductName( review ) {
5656
return (
5757
<div className="wc-block-review-list-item__product">
58-
<a href={ review.product_permalink }>
59-
{ review.product_name }
60-
</a>
58+
<a
59+
href={ review.product_permalink }
60+
dangerouslySetInnerHTML={ {
61+
// `product_name` might have html entities for things like
62+
// emdash. So to display properly we need to allow the
63+
// browser to render.
64+
__html: review.product_name,
65+
} }
66+
/>
6167
</div>
6268
);
6369
}
@@ -128,4 +134,13 @@ ReviewListItem.propTypes = {
128134
review: PropTypes.object,
129135
};
130136

137+
/**
138+
* BE AWARE. ReviewListItem expects product data that is equivalent to what is
139+
* made avaialble for output in a public view. Thus content that may contain
140+
* html data is not sanitized further.
141+
*
142+
* Currently the following data is trusted (assumed to already be sanitized):
143+
* - `review.review` (review content).
144+
* - `review.product_name` (the product title)
145+
*/
131146
export default ReviewListItem;

0 commit comments

Comments
 (0)