Bug 42010

Summary: Include escaping when using PO numbers in EDI acqusitions
Product: Koha Reporter: Martin Renvoize (ashimema) <martin.renvoize>
Component: AcquisitionsAssignee: Martin Renvoize (ashimema) <martin.renvoize>
Status: Needs Signoff --- QA Contact: Testopia <testopia>
Severity: major    
Priority: P5 - low CC: hdunne-howrie, kyle, testopia
Version: Main   
Hardware: All   
OS: All   
GIT URL: Initiative type: ---
Sponsorship status: Unsponsored Comma delimited list of Sponsors:
Crowdfunding goal: 0 Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Bug Depends on: 20253    
Bug Blocks: 38195    
Attachments: Bug 42010: Escape EDIFACT special characters in BGM purchase order number

Description Martin Renvoize (ashimema) 2026-03-06 10:25:11 UTC
In bug #20253 we added support for using PO numbers as basket names.. we neglected to add escaping to the resulting basketnames that could then be used in corresponding orders.

This bug servers to add that escaping as a follow-up to the original enhancement.
Comment 1 Martin Renvoize (ashimema) 2026-03-06 10:30:16 UTC
Created attachment 194624 [details] [review]
Bug 42010: Escape EDIFACT special characters in BGM purchase order number

Bug 20253 introduced the ability to use the basket name as a purchase order
number in the BGM segment of an EDIFACT order message. However, the basket
name was inserted into the BGM segment without escaping EDIFACT special
characters (apostrophe, colon, plus, question mark).

In EDIFACT, the apostrophe (') is the segment terminator, so any literal
apostrophe in data must be escaped with the release character (?) as ?'.
Without this, a basket name like "Children's Requests" would produce an
invalid EDIFACT message.

This fix applies encode_text() to the purchase order number in
beginning_of_message() so all special characters are properly escaped.

Test plan:
- Run t/db_dependent/Koha/Edifact/Order.t
- All tests should pass, including the new tests covering special character
  escaping in BGM segments