Bug 41818

Summary: SIP2 message in AF field should be stripped of newlines and carriage returns
Product: Koha Reporter: Jake Deery <jake.deery>
Component: SIP2Assignee: Jake Deery <jake.deery>
Status: Needs Signoff --- QA Contact: Testopia <testopia>
Severity: trivial    
Priority: P5 - low CC: hdunne-howrie
Version: Main   
Hardware: All   
OS: All   
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: Bug 41818: Add new Koha::Patron::Message method to SIP2

Description Jake Deery 2026-02-11 13:54:16 UTC
SIP2 places patron messages in the AF field, to be displayed on the unit, should a staff member wish them to be seen.

The field in the staff client accepts multi-line input, but SIP2 units generally use either newline, carriage return, or both, as an indicator of the end of a message.

There should be a message_without_newlines method under Koha::Patron::Message to handle scenarios like this, where the newlines are not desirable.
Comment 1 Jake Deery 2026-02-11 14:49:22 UTC
Created attachment 192982 [details] [review]
Bug 41818: Add new Koha::Patron::Message method to SIP2

This bug adds Koha::Patron::Message::message_without_newlines, which has been added to C4::SIP::ILS::Patron in lieu of Koha::Patron::Message::message. The aim of this change is to prevent SIP2 units from crashing out when they encounter a patron message with newlines (\n or \r) in it, as units generally use a newline character to denote the end of a SIP2 transaction.

To test:
a)  go to /cgi-bin/koha/sip2/institutions
    *)  create an institution, name CPL, timeout 300, the rest default
b)  go to /cgi-bin/koha/sip2/accounts
    *)  create an account, userid koha, institution CPL, terminator crlf, the rest default
c)  go to /cgi-bin/koha/members/moremember.pl?borrowernumber=51
    *)  click add message in toolbar
    *)  enter some multi-line message e.g. test[RETURN]1[RETURN]2[RETURN]3[RETURN][RETURN][RETURN]
d)  run tail -f /var/log/koha/kohadev/sip-output.log, keep this window open
e)  run ./misc/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su koha -sp koha -l CPL --patron 42 -m patron_information
f)  look at the tail log, notice how the MSG 64 line has a newline before the final pipe (|) character
== APPLY PATCH ==
g)  restart_all
h)  repeat steps e-f
i)  notice how in the tail log, the MSG 64 line now has the final pipe character contiguously placed with the successive characters
== SIGN OFF ==