From: Jason Stephenson Date: Thu, 30 Jul 2015 13:38:55 +0000 (-0400) Subject: Some defensive coding in NCIP::ILS.pm. X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=e6a82bdecc0c1e33e00f195f93d9f1bcf2e8277a;p=NCIPServer.git 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 --- 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); } }