@@ -, +, @@ apostrophe --- Koha/Edifact/Order.pm | 2 +- t/Ediorder.t | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) --- a/Koha/Edifact/Order.pm +++ a/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; --- a/t/Ediorder.t +++ a/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'; --