My personal BigCommerce sandbox developer store
0

Configure Feed

Select the types of activity you want to include in your feed.

fix(storefront): BCTHEME-313 Parse HTML entities in jsContext (#1917)

authored by

Brian Davenport and committed by
GitHub
(Dec 8, 2020, 4:15 PM +0200) 3fda220a 6dbf3c52

+13 -3
+4 -3
assets/js/theme/product/reviews.js
··· 1 1 import nod from '../common/nod'; 2 2 import { CollapsibleEvents } from '../common/collapsible'; 3 3 import forms from '../common/models/forms'; 4 + import { safeString } from '../common/utils/safe-string'; 4 5 5 6 export default class { 6 7 constructor($reviewForm) { ··· 62 63 this.validator.add([{ 63 64 selector: '[name="revrating"]', 64 65 validate: 'presence', 65 - errorMessage: this.context.reviewRating, 66 + errorMessage: safeString(this.context.reviewRating), 66 67 }, { 67 68 selector: '[name="revtitle"]', 68 69 validate: 'presence', 69 - errorMessage: this.context.reviewSubject, 70 + errorMessage: safeString(this.context.reviewSubject), 70 71 }, { 71 72 selector: '[name="revtext"]', 72 73 validate: 'presence', 73 - errorMessage: this.context.reviewComment, 74 + errorMessage: safeString(this.context.reviewComment), 74 75 }, { 75 76 selector: '.writeReview-form [name="email"]', 76 77 validate: (cb, val) => {
+9
assets/js/theme/common/utils/safe-string.js
··· 1 + /** 2 + * This function parses HTML entities in strings 3 + * @param str: String 4 + * @returns String 5 + */ 6 + export const safeString = (str) => { 7 + const d = new DOMParser(); 8 + return d.parseFromString(str, 'text/html').body.textContent; 9 + };