Skip to content

Commit 3add495

Browse files
committed
ACP2E-103: Pagebuilder content gets corrupted, when 4 bytes characters like emojis are used
1 parent ac88ad9 commit 3add495

File tree

1 file changed

+17
-0
lines changed
  • app/code/Magento/Ui/view/base/web/js/lib/validation

1 file changed

+17
-0
lines changed

app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,23 @@ define([
11011101
return moment.utc(value, params.dateFormat).isSameOrBefore(moment.utc());
11021102
},
11031103
$.mage.__('The Date of Birth should not be greater than today.')
1104+
],
1105+
/* detect chars that would require more than 3 bytes */
1106+
'validate-no-utf8mb4-characters': [
1107+
function (value) {
1108+
var validator = this,
1109+
message = $.mage.__('Please remove invalid characters: {0}.'),
1110+
matches = value.match(/(?:[\uD800-\uDBFF][\uDC00-\uDFFF])/g),
1111+
result = matches === null;
1112+
1113+
if (!result) {
1114+
validator.charErrorMessage = message.replace('{0}', matches.join());
1115+
}
1116+
1117+
return result;
1118+
}, function () {
1119+
return this.charErrorMessage;
1120+
}
11041121
]
11051122
}, function (data) {
11061123
return {

0 commit comments

Comments
 (0)