From 264cddee0c9a5251f1c8e1b8803a1aa4093dbbd6 Mon Sep 17 00:00:00 2001 From: Bernard Scaife Date: Wed, 27 Aug 2025 16:25:25 +0100 Subject: [PATCH] Bug 40675: Fix SIP message corruption from embedded line endings Patron messages containing carriage returns, line feeds, or CRLF combinations can break SIP protocol communication since CR is used as the SIP message terminator. This causes message parsing failures and protocol errors in self-check systems. The previous regex only handled single carriage returns (\r), missing Windows CRLF (\r\n) and Unix LF (\n) sequences. This patch normalizes all line ending variations to spaces to prevent SIP message corruption while preserving message content. Test plan: 1. Go to a patron record and click "Add message" 2. Select "Add message for OPAC..." from dropdown 3. In a text editor (e.g., Word), create a message with line breaks: "This is line one[Enter]This is line two[Enter]This is line three" 4. Copy and paste this multi-line text into the message box and save 5. Run the SIP emulator: misc/sip_cli_emulator.pl 6. Execute a patron information request for this patron 7. Before patch: Observe message breaks at line endings, corrupting the SIP response 8. Apply patch and restart SIP server 9. Repeat steps 5-6 10. After patch: Verify the message appears as single line with spaces replacing line breaks: "This is line one This is line two This is line three" 11. Test with different line ending types (Windows, Mac, Unix) to ensure all variations are handled correctly Signed-off-by: Martin Renvoize --- C4/SIP/Sip.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/C4/SIP/Sip.pm b/C4/SIP/Sip.pm index c4cff7ee94a..f48a36e97e2 100644 --- a/C4/SIP/Sip.pm +++ b/C4/SIP/Sip.pm @@ -97,8 +97,8 @@ sub add_field { ); $value = ''; } - $value =~ s/\r/ /g; # CR terminates a sip message - # Protect against them in sip text fields + $value =~ s/\r\n|\r|\n/ /g; # CR terminates a sip message + # Protect against them in sip text fields # Replace any occurrences of the field delimiter in the # field value with the HTML character entity -- 2.51.0