Bugzilla – Attachment 192982 Details for
Bug 41818
SIP2 message in AF field should be stripped of newlines and carriage returns
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 41818: Add new Koha::Patron::Message method to SIP2
988196d.patch (text/plain), 3.11 KB, created by
Jake Deery
on 2026-02-11 14:49:22 UTC
(
hide
)
Description:
Bug 41818: Add new Koha::Patron::Message method to SIP2
Filename:
MIME Type:
Creator:
Jake Deery
Created:
2026-02-11 14:49:22 UTC
Size:
3.11 KB
patch
obsolete
>From 988196d75da490ffaecf9e66845ef0e6b75d8f7d Mon Sep 17 00:00:00 2001 >From: Jake Deery <jake.deery@openfifth.co.uk> >Date: Wed, 11 Feb 2026 13:54:47 +0000 >Subject: [PATCH] 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 == >--- > C4/SIP/ILS/Patron.pm | 2 +- > Koha/Patron/Message.pm | 21 +++++++++++++++++++++ > 2 files changed, 22 insertions(+), 1 deletion(-) > >diff --git a/C4/SIP/ILS/Patron.pm b/C4/SIP/ILS/Patron.pm >index 5a387c14514..bb967df373d 100644 >--- a/C4/SIP/ILS/Patron.pm >+++ b/C4/SIP/ILS/Patron.pm >@@ -215,7 +215,7 @@ sub new { > while ( my $message = $patron_messages->next ) { > my $messagedt = dt_from_string( $message->message_date, 'iso' ); > my $formatted_date = output_pref( { dt => $messagedt, dateonly => 1 } ); >- push @messages_array, $formatted_date . ": " . $message->message; >+ push @messages_array, $formatted_date . ": " . $message->message_without_newlines; > } > if (@messages_array) { > $ilspatron{screen_msg} .= " Messages for you: " . join( ' / ', @messages_array ); >diff --git a/Koha/Patron/Message.pm b/Koha/Patron/Message.pm >index 8ba6138da95..884c4b42414 100644 >--- a/Koha/Patron/Message.pm >+++ b/Koha/Patron/Message.pm >@@ -77,6 +77,27 @@ sub delete { > return $self->SUPER::delete($self); > } > >+=head3 message_without_newlines >+ >+my $message_without_newlines = $message->message_without_newlines >+ >+This method returns the user's message, with all instances of \n and \r removed >+ >+=cut >+ >+sub message_without_newlines { >+ my ($self) = @_; >+ my $message = $self->message >+ or return; >+ >+ $message =~ s/\n/ /g; >+ $message =~ s/\r//g; >+ $message =~ s/^\s+|\s+$//g; # left and right trim >+ $message =~ s/ +/ /g; # duplicate spaces >+ >+ return $message; >+} >+ > =head3 _type > > =cut >-- >2.50.1 (Apple Git-155) >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 41818
: 192982