Skip to content

Commit fc36590

Browse files
author
Daniele Donnini
committed
Bugfix for regions with single quote in name
Before this bugfix, changing the country of a customer address use to generate a jQuery exception that breaks the options population if a region of that country has a name containg one of the css meta-characters. For example, selecting France the option Côtes-d'Armor breaks jQuery.
1 parent c913c94 commit fc36590

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

app/code/Magento/Checkout/view/frontend/web/js/region-updater.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@ define([
6060
*/
6161
_renderSelectOption: function(selectElement, key, value) {
6262
selectElement.append($.proxy(function() {
63-
if (value.code && $(value.name).is('span')) {
63+
var name = value.name.replace(/[!"#$%&'()*+,.\/:;<=>?@[\\\]^`{|}~]/g, "\\$&");
64+
if (value.code && $(name).is('span')) {
6465
key = value.code;
65-
value.name = $(value.name).text();
66+
value.name = $(name).text();
6667
}
6768
$.template('regionTemplate', this.options.regionTemplate);
6869
if (this.options.defaultRegion === key) {
@@ -172,4 +173,4 @@ define([
172173
});
173174

174175
return $.mage.regionUpdater;
175-
});
176+
});

dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/UpdateCustomerFrontendEntity.php renamed to dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/UpdateCustomerFrontendEntityTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
3939
*/
40-
class UpdateCustomerFrontendEntity extends Injectable
40+
class UpdateCustomerFrontendEntityTest extends Injectable
4141
{
4242
/**
4343
* Factory for Fixtures
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
"customer/data/firstname";"customer/data/lastname";"customer/data/email";"address/data/firstname";"address/data/lastname";"address/data/company";"address/data/street";"address/data/city";"address/data/country_id";"address/data/region_id";"address/data/region";"address/data/telephone";"address/data/fax";"address/data/postcode";"constraint"
22
"Jany %isolation%";"Doe %isolation%";"janydoe%isolation%@example.com";"Jany %isolation%";"Doe %isolation%";"Company %isolation%";"Some street %isolation%";"City %isolation%";"United States";"Colorado";"-";"555-888-111-999";"161-999-8888";"12345";"assertCustomerAddressSuccessSaveMessage, assertCustomerDefaultAddresses"
33
"Jonny %isolation%";"Doe %isolation%";"jonny%isolation%@example.com";"John %isolation%";"Doe %isolation%";"Company %isolation%";"Some street %isolation%";"City %isolation%";"United Kingdom";"-";"Region %isolation%";"0123456789-02134567";"5555-874-99634";"12345";"assertCustomerAddressSuccessSaveMessage, assertCustomerDefaultAddresses"
4+
"Jean %isolation%";"Reno %isolation%";"jean%isolation%@example.com";"Jean %isolation%";"Reno %isolation%";"Magento %isolation%";"18-20 Rue Maréchal Leclerc";"Quintin";"France";"Côtes-d'Armor";"-";"555-888-111-999";"161-999-8888";"12345";"assertCustomerAddressSuccessSaveMessage, assertCustomerDefaultAddresses"

0 commit comments

Comments
 (0)