From 5cf2b4f108bee22a8a8a4fe4fb0f91cbc08e74e0 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 Content-Type: text/plain; charset=utf-8 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 --- C4/Acquisition.pm | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index f17402f..ac5415b 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.1.4