From 152c1f76c27fad50e1fbd4a494b7e0b251eb7b4f Mon Sep 17 00:00:00 2001 From: Thomas Berezansky Date: Thu, 22 Sep 2011 09:24:56 -0400 Subject: [PATCH] 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 Signed-off-by: Mike Rylander --- Open-ILS/xul/staff_client/chrome/content/util/barcode.js | 3 +++ 1 file changed, 3 insertions(+) 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; -- 2.11.0