From 9ca8275862e5730595fdd99d90295c90ba708e15 Mon Sep 17 00:00:00 2001 From: Josef Moravec Date: Thu, 4 May 2017 07:43:27 +0000 Subject: [PATCH] Bug 8612: [Follow-up] Fix regular expression Fix regular expression to do what is described in the comment Make header in CSV profile definition optional Strip white chars from csv profile definition Signed-off-by: Marcel de Rooy Signed-off-by: Jonathan Druart --- C4/Acquisition.pm | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index 22dee154dc..16f442460d 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -295,14 +295,19 @@ sub GetBasketAsCSV { my $csv_profile_content = $csv_profile->content; my ( @headers, @fields ); while ( $csv_profile_content =~ / - ([^=]+) # header - = - ([^\|]+) # fieldname (table.row or row) + ([^=\|]+) # header + =? + ([^\|]*) # fieldname (table.row or row) \|? /gxms ) { - push @headers, $1; - my $field = $2; - $field =~ s/[^\.]*\.?//; # Remove the table name if exists. + my $header = $1; + my $field = ($2 eq '') ? $1 : $2; + + $header =~ s/^\s+|\s+$//g; # Trim whitespaces + push @headers, $header; + + $field =~ s/[^\.]*\.{1}//; # Remove the table name if exists. + $field =~ s/^\s+|\s+$//g; # Trim whitespaces push @fields, $field; } for my $order (@orders) { -- 2.39.5