Skip to content

Commit f85fc39

Browse files
committed
ACP2E-1444: [Page Builder] Product widget does not work with SKUs containing '&'
1 parent d3d2d71 commit f85fc39

File tree

4 files changed

+72
-4
lines changed

4 files changed

+72
-4
lines changed

app/code/Magento/PageBuilder/view/adminhtml/web/js/content-type/products/mass-converter/carousel-widget-directive.js

Lines changed: 17 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/code/Magento/PageBuilder/view/adminhtml/web/js/content-type/products/mass-converter/widget-directive.js

Lines changed: 17 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/content-type/products/mass-converter/carousel-widget-directive.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ export default class WidgetDirective extends BaseWidgetDirective {
3030
data.carousel_products_count = attributes.products_count;
3131
data.sort_order = attributes.sort_order;
3232
data.condition_option = attributes.condition_option || "condition";
33-
data[data.condition_option] = this.decodeWysiwygCharacters(attributes.condition_option_value || "");
33+
data[data.condition_option] = this.decodeWysiwygCharacters(
34+
this.decodeHtmlCharacters(attributes.condition_option_value || ""),
35+
);
3436
data.conditions_encoded = this.decodeWysiwygCharacters(attributes.conditions_encoded || "");
3537
data[data.condition_option + "_source"] = data.conditions_encoded;
3638
return data;
@@ -98,4 +100,20 @@ export default class WidgetDirective extends BaseWidgetDirective {
98100
.replace(/&lt;/g, "<")
99101
.replace(/&gt;/g, ">");
100102
}
103+
104+
/**
105+
* Decode html special characters
106+
*
107+
* @param {string} content
108+
* @returns {string}
109+
*/
110+
private decodeHtmlCharacters(content: string) {
111+
if (content) {
112+
const htmlDocument = new DOMParser().parseFromString(content, "text/html");
113+
114+
return htmlDocument.body ? htmlDocument.body.textContent : content;
115+
}
116+
117+
return content;
118+
}
101119
}

app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/content-type/products/mass-converter/widget-directive.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ export default class WidgetDirective extends BaseWidgetDirective {
3030
data.products_count = attributes.products_count;
3131
data.sort_order = attributes.sort_order;
3232
data.condition_option = attributes.condition_option || "condition";
33-
data[data.condition_option] = this.decodeWysiwygCharacters(attributes.condition_option_value || "");
33+
data[data.condition_option] = this.decodeWysiwygCharacters(
34+
this.decodeHtmlCharacters(attributes.condition_option_value || ""),
35+
);
3436
data.conditions_encoded = this.decodeWysiwygCharacters(attributes.conditions_encoded || "");
3537
data[data.condition_option + "_source"] = data.conditions_encoded;
3638
return data;
@@ -98,4 +100,20 @@ export default class WidgetDirective extends BaseWidgetDirective {
98100
.replace(/&lt;/g, "<")
99101
.replace(/&gt;/g, ">");
100102
}
103+
104+
/**
105+
* Decode html special characters
106+
*
107+
* @param {string} content
108+
* @returns {string}
109+
*/
110+
private decodeHtmlCharacters(content: string) {
111+
if (content) {
112+
const htmlDocument = new DOMParser().parseFromString(content, "text/html");
113+
114+
return htmlDocument.body ? htmlDocument.body.textContent : content;
115+
}
116+
117+
return content;
118+
}
101119
}

0 commit comments

Comments
 (0)