From e6a82bdecc0c1e33e00f195f93d9f1bcf2e8277a Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Thu, 30 Jul 2015 09:38:55 -0400 Subject: [PATCH] Some defensive coding in NCIP::ILS.pm. XML::LibXML::Simple will return {} for an empty field. We need to check this on barcode input, at least, and undef the variable. This is done in the base class find_user_barcode and find_item_barcode methods. Signed-off-by: Jason Stephenson --- lib/NCIP/ILS.pm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/NCIP/ILS.pm b/lib/NCIP/ILS.pm index ef64d93..6e654c2 100644 --- a/lib/NCIP/ILS.pm +++ b/lib/NCIP/ILS.pm @@ -348,6 +348,9 @@ sub find_user_barcode { } } + # Because XML::LibXML::Simple returns {} for empty text values. + undef($barcode) if (ref($barcode) eq 'HASH' && !%{$barcode}); + return (wantarray) ? ($barcode, $field) : $barcode; } @@ -386,6 +389,8 @@ sub find_item_barcode { next unless ($input->{ItemIdentifierType} =~ /barcode/i); } $barcode = $input->{ItemIdentifierValue}; + # Because XML::LibXML::Simple returns {} for empty text values. + undef($barcode) if (ref($barcode) eq 'HASH' && !%{$barcode}); last if ($barcode); } } -- 2.43.2