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 <hayleymapley@catalyst.net.nz>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
(cherry picked from commit 0c4112a200)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit d991ffdbee)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Colin Campbell 2019-07-02 10:58:41 +01:00 committed by Lucas Gass
parent 23130a90ed
commit cf43db0a22
2 changed files with 13 additions and 2 deletions

View File

@ -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;

View File

@ -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';