Bug 1372427 - force radix argument in parseInt. r=mattn draft
authorJonathan Guillotte-Blouin <jguillotteblouin@mozilla.com>
Wed, 14 Jun 2017 13:38:17 -0700
changeset 597781 c7686e8dae545face3dc7d66e1a1f76513630254
parent 597780 621c4656a1b3c900256811416d3c07007ee4a91b
child 597782 86f4927be8cf70599971b1f8aad8b72ca3d295ff
child 597794 cfe0246ca4f8be7adc020a1bba701ab1a44fbe02
push id65025
push userbmo:jguillotteblouin@mozilla.com
push dateTue, 20 Jun 2017 23:10:16 +0000
reviewersmattn
bugs1372427
milestone56.0a1
Bug 1372427 - force radix argument in parseInt. r=mattn MozReview-Commit-ID: J4VoeedZpGa
toolkit/components/satchel/.eslintrc.js
toolkit/components/satchel/formSubmitListener.js
toolkit/components/satchel/test/unit/test_autocomplete.js
--- 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)");