From d991ffdbee43984a592645a1b5624007bef96679 Mon Sep 17 00:00:00 2001 From: Colin Campbell Date: Tue, 2 Jul 2019 10:58:41 +0100 Subject: [PATCH] Bug 23251: Correct formatting of IMD data ending in apostrophe IMD text data may end in an apostrophe (e.g. dreamin' ) This was causing the segment to be incorrectly formatted as only the last character was checked, not the preceding character to check whether it was quoted add a test for this specific occurence Signed-off-by: Hayley Mapley Signed-off-by: Kyle M Hall Signed-off-by: Martin Renvoize (cherry picked from commit 0c4112a200bfdcdbdba4ce7870aeced1f960cfd9) Signed-off-by: Fridolin Somers --- Koha/Edifact/Order.pm | 2 +- t/Ediorder.t | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Koha/Edifact/Order.pm b/Koha/Edifact/Order.pm index 9822526a3b..062a2f930a 100644 --- a/Koha/Edifact/Order.pm +++ b/Koha/Edifact/Order.pm @@ -512,7 +512,7 @@ sub imd_segment { } $odd = !$odd; } - if ( @segs && $segs[-1] !~ m/$seg_terminator$/o ) { + if ( @segs && $segs[-1] !~ m/[^?]$seg_terminator$/o ) { $segs[-1] .= $seg_terminator; } return @segs; diff --git a/t/Ediorder.t b/t/Ediorder.t index 50926a9127..ceeb647371 100755 --- a/t/Ediorder.t +++ b/t/Ediorder.t @@ -3,7 +3,7 @@ use strict; use warnings; use FindBin qw( $Bin ); -use Test::More tests => 8; +use Test::More tests => 10; BEGIN { use_ok('Koha::Edifact::Order') } @@ -55,6 +55,17 @@ $data_to_encode .= '??'; cmp_ok( $segs[1], 'eq', q{IMD+L+010+:::CCCCCCCCCC??'}, 'IMD segment deals with quoted character at end' ); +# special case for text ending in apostrophe e.g. nuthin' +$data_to_encode .= q{?'}; +@segs = Koha::Edifact::Order::imd_segment( $code, $data_to_encode ); +cmp_ok( $segs[1], 'eq', q{IMD+L+010+:::CCCCCCCCCC???''}, + 'IMD segment deals with quoted apostrophe at end' ); + +$data_to_encode =~s/\?'$//; +@segs = Koha::Edifact::Order::imd_segment( $code, $data_to_encode ); +cmp_ok( $segs[1], 'eq', q{IMD+L+010+:::CCCCCCCCCC??'}, + 'IMD segment deals with apostrophe preceded by quoted ? at end' ); + my $isbn = '3540556753'; my $ean = '9783540556756'; -- 2.39.5