From: Thomas Berezansky <tsbere@mvlc.org>
Date: Thu, 22 Sep 2011 13:24:56 +0000 (-0400)
Subject: Throw out non-digit barcodes for strict check
X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=152c1f76c27fad50e1fbd4a494b7e0b251eb7b4f;p=evergreen%2Fmasslnc.git

Throw out non-digit barcodes for strict check

Characters like "." are valid for numbers, but not the algorithm.

Thus, we need to throw out "16.00" despite the check for
"16.00" == Number("16.00")
returning true.

Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
---

diff --git a/Open-ILS/xul/staff_client/chrome/content/util/barcode.js b/Open-ILS/xul/staff_client/chrome/content/util/barcode.js
index 4d8880771e..8d30a20b16 100644
--- a/Open-ILS/xul/staff_client/chrome/content/util/barcode.js
+++ b/Open-ILS/xul/staff_client/chrome/content/util/barcode.js
@@ -11,6 +11,9 @@ util.barcode.EXPORT_TAGS    = { ':all' : util.barcode.EXPORT_OK };
 util.barcode.check = function(bc) {
     if (bc != Number(bc)) return false;
     bc = bc.toString();
+    // "16.00" == Number("16.00"), but the . is bad.
+    // Throw out any barcode that isn't just digits
+    if (bc.search(/\D/) != -1) return false;
     var last_digit = bc.substr(bc.length-1);
     var stripped_barcode = bc.substr(0,bc.length-1);
     return util.barcode.checkdigit(stripped_barcode).toString() == last_digit;