Bug 1372427 - force radix argument in parseInt. r=mattn
MozReview-Commit-ID: J4VoeedZpGa
--- a/toolkit/components/satchel/.eslintrc.js
+++ b/toolkit/components/satchel/.eslintrc.js
@@ -43,10 +43,11 @@ module.exports = {
"dot-location": ["error", "property"],
"max-len": ["error", 100],
"no-fallthrough": "error",
"no-multiple-empty-lines": ["error", {
max: 2,
}],
"no-throw-literal": "error",
"padded-blocks": ["error", "never"],
+ radix: "error",
},
};
--- a/toolkit/components/satchel/formSubmitListener.js
+++ b/toolkit/components/satchel/formSubmitListener.js
@@ -45,17 +45,17 @@ var satchelFormListener = {
}
if (!/^\d+$/.test(ccNumber)) {
return false;
}
let total = 0;
for (let i = 0; i < len; i++) {
- let ch = parseInt(ccNumber[len - i - 1]);
+ let ch = parseInt(ccNumber[len - i - 1], 10);
if (i % 2 == 1) {
// Double it, add digits together if > 10
ch *= 2;
if (ch > 9) {
ch -= 9;
}
}
total += ch;
--- a/toolkit/components/satchel/test/unit/test_autocomplete.js
+++ b/toolkit/components/satchel/test/unit/test_autocomplete.js
@@ -140,31 +140,31 @@ add_test(function test5() {
add_test(function test6() {
do_log_info("Check search result ordering with empty search term");
let lastFound = timesUsedSamples;
fac.autoCompleteSearchAsync("field2", "", null, null, null, {
onSearchCompletion(aResults) {
for (let i = 0; i < timesUsedSamples; i++) {
- do_check_eq(parseInt(aResults.getValueAt(i).substr(5)), --lastFound);
+ do_check_eq(parseInt(aResults.getValueAt(i).substr(5), 10), --lastFound);
}
run_next_test();
}
});
});
add_test(function test7() {
do_log_info("Check search result ordering with \"v\"");
let lastFound = timesUsedSamples;
fac.autoCompleteSearchAsync("field2", "v", null, null, null, {
onSearchCompletion(aResults) {
for (let i = 0; i < timesUsedSamples; i++) {
- do_check_eq(parseInt(aResults.getValueAt(i).substr(5)), --lastFound);
+ do_check_eq(parseInt(aResults.getValueAt(i).substr(5), 10), --lastFound);
}
run_next_test();
}
});
});
add_test(function test8() {
do_log_info("Check that \"senior citizen\" entries get a bonus (browser.formfill.agedBonus)");