Bug 1382529 - [Form Autofill] Exception occurs when saving a telephone number like "1234567". r=steveck
MozReview-Commit-ID: mJ3KJemnme
--- a/browser/extensions/formautofill/ProfileStorage.jsm
+++ b/browser/extensions/formautofill/ProfileStorage.jsm
@@ -962,17 +962,17 @@ class Addresses extends AutofillRecords
number = address["tel-national"];
} else if (address["tel-local"]) {
number = (address["tel-area-code"] || "") + address["tel-local"];
} else if (address["tel-local-prefix"] && address["tel-local-suffix"]) {
number = (address["tel-area-code"] || "") + address["tel-local-prefix"] + address["tel-local-suffix"];
}
let tel = PhoneNumber.Parse(number, region);
- if (tel) {
+ if (tel && tel.internationalNumber) {
// Force to save numbers in E.164 format if parse success.
address.tel = tel.internationalNumber;
} else if (!address.tel) {
// Save the original number anyway if "tel" is omitted.
address.tel = number;
}
TEL_COMPONENTS.forEach(c => delete address[c]);
--- a/browser/extensions/formautofill/test/unit/test_transformFields.js
+++ b/browser/extensions/formautofill/test/unit/test_transformFields.js
@@ -386,16 +386,25 @@ const ADDRESS_NORMALIZE_TESTCASES = [
address: {
"tel": "12345",
},
expectedResult: {
"tel": "12345",
},
},
{
+ description: "Has a valid tel-local format \"tel\"",
+ address: {
+ "tel": "1234567",
+ },
+ expectedResult: {
+ "tel": "1234567",
+ },
+ },
+ {
description: "Has \"tel-national\" and \"tel-country-code\"",
address: {
"tel-national": "0212345678",
"tel-country-code": "+886",
},
expectedResult: {
"tel": "+886212345678",
},