Bug 41789 - EDIFACT messages broken by unidecode
Summary: EDIFACT messages broken by unidecode
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: Acquisitions (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-02-06 15:31 UTC by Andreas Jonsson
Modified: 2026-02-06 15:31 UTC (History)
0 users

See Also:
GIT URL:
Initiative type: ---
Sponsorship status: ---
Comma delimited list of Sponsors:
Crowdfunding goal: 0
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Jonsson 2026-02-06 15:31:57 UTC
In EDI.pm EDIFACT messages are built and the result is passed to unidecode.  However, unidecode replace unicode characters with the transliterated ascii characters which may include characters that have special meaning including apostrophe '.

    my $order_file = $edifact->encode();

    # ingest result
    if ($order_file) {
        my $m = unidecode($order_file);    # remove diacritics and non-latin chars

But this must be done before escaping special characters. For instance:

diff --git a/Koha/Edifact/Order.pm b/Koha/Edifact/Order.pm
index a36bd7e1b5b..096e66d5f3e 100644
--- a/Koha/Edifact/Order.pm
+++ b/Koha/Edifact/Order.pm
@@ -27,6 +27,7 @@ use Readonly qw( Readonly );
 use Koha::Database;
 use Koha::DateUtils qw( dt_from_string );
 use C4::Budgets     qw( GetBudget );
+use Text::Unidecode qw( unidecode );
 
 use Koha::Acquisition::Orders;
 
@@ -685,6 +686,7 @@ sub _interchange_sr_identifier {
 sub encode_text {
     my $string = shift;
     if ($string) {
+        $string = unidecode( $string );
         $string =~ s/[?]/??/g;
         $string =~ s/'/?'/g;
         $string =~ s/:/?:/g;