From c914473e811d6670a7195b11dc09cddc08182c24 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 25 Sep 2023 11:29:20 +0100 Subject: [PATCH] Bug 34737: (follow-up) Code more defensively This patch adds some defense for errant preference lines, allowing for empty lines, comment lines and even skipping easily identified malformed lines. Signed-off-by: Toni Ford Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi --- C4/SIP/ILS/Transaction/Checkin.pm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/C4/SIP/ILS/Transaction/Checkin.pm b/C4/SIP/ILS/Transaction/Checkin.pm index bf4a17720a..0ddbaa8f21 100644 --- a/C4/SIP/ILS/Transaction/Checkin.pm +++ b/C4/SIP/ILS/Transaction/Checkin.pm @@ -268,6 +268,16 @@ sub _get_sort_bin { my $rule = 0; RULE: foreach my $line (@lines) { + # Skip empty lines and comments + next if ( $line =~ /^\s*($|#)/ ); + + # Skip malformed lines + my $count = () = $line =~ /\Q:/g; + if ( --$count % 3 ) { + warn "Malformed preference line found: '$line'"; + next; + } + my $match = 0; # Split the line into fields -- 2.39.5