Bugzilla – Attachment 186609 Details for
Bug 40675
Carriage return in patron note message breaks SIP
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40675: Add unit tests for SIP line ending normalization
Bug-40675-Add-unit-tests-for-SIP-line-ending-norma.patch (text/plain), 2.71 KB, created by
Marcel de Rooy
on 2025-09-19 08:32:50 UTC
(
hide
)
Description:
Bug 40675: Add unit tests for SIP line ending normalization
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2025-09-19 08:32:50 UTC
Size:
2.71 KB
patch
obsolete
>From 4bb4f6b90779629580d96c6a434a7d6db78f0471 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Date: Tue, 16 Sep 2025 10:08:56 +0100 >Subject: [PATCH] Bug 40675: Add unit tests for SIP line ending normalization >Content-Type: text/plain; charset=utf-8 > >This patch adds comprehensive unit tests for the add_field function >to verify that all types of line endings (Unix \n, Windows \r\n, >Mac \r, and mixed) are properly normalized to spaces to prevent >SIP message corruption. > >Tests cover: >- Unix line endings (\n) >- Windows line endings (\r\n) >- Mac line endings (\r) >- Mixed line ending combinations >- Normal text without line endings >- Empty values >--- > t/SIP/Sip.t | 32 ++++++++++++++++++++++++++++++-- > 1 file changed, 30 insertions(+), 2 deletions(-) > >diff --git a/t/SIP/Sip.t b/t/SIP/Sip.t >index 800de5146f..f39a45d13e 100755 >--- a/t/SIP/Sip.t >+++ b/t/SIP/Sip.t >@@ -18,11 +18,11 @@ > use Modern::Perl; > > use Test::NoWarnings; >-use Test::More tests => 11; >+use Test::More tests => 12; > use Test::Warn; > > BEGIN { >- use_ok( 'C4::SIP::Sip', qw( timestamp ) ); >+ use_ok( 'C4::SIP::Sip', qw( timestamp add_field ) ); > } > > my $date_time = C4::SIP::Sip::timestamp(); >@@ -114,3 +114,31 @@ subtest 'remove_password_from_message' => sub { > "11 Checkout - empty AC and AND" > ); > }; >+ >+subtest 'add_field line ending normalization' => sub { >+ plan tests => 6; >+ >+ # Test Unix line endings (\n) >+ my $field_unix = C4::SIP::Sip::add_field( "AF", "Line one\nLine two\nLine three" ); >+ is( $field_unix, "AFLine one Line two Line three|", "Unix line endings (\\n) converted to spaces" ); >+ >+ # Test Windows line endings (\r\n) >+ my $field_windows = C4::SIP::Sip::add_field( "AF", "Line one\r\nLine two\r\nLine three" ); >+ is( $field_windows, "AFLine one Line two Line three|", "Windows line endings (\\r\\n) converted to spaces" ); >+ >+ # Test Mac line endings (\r) >+ my $field_mac = C4::SIP::Sip::add_field( "AF", "Line one\rLine two\rLine three" ); >+ is( $field_mac, "AFLine one Line two Line three|", "Mac line endings (\\r) converted to spaces" ); >+ >+ # Test mixed line endings >+ my $field_mixed = C4::SIP::Sip::add_field( "AF", "Line one\r\nLine two\nLine three\rLine four" ); >+ is( $field_mixed, "AFLine one Line two Line three Line four|", "Mixed line endings converted to spaces" ); >+ >+ # Test no line endings (should remain unchanged) >+ my $field_normal = C4::SIP::Sip::add_field( "AF", "Single line message" ); >+ is( $field_normal, "AFSingle line message|", "Normal text without line endings unchanged" ); >+ >+ # Test empty and undefined values >+ my $field_empty = C4::SIP::Sip::add_field( "AF", "" ); >+ is( $field_empty, "AF|", "Empty value handled correctly" ); >+}; >-- >2.39.5
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 40675
:
185583
|
185791
|
185792
|
185793
|
185794
|
185802
|
185833
|
186456
|
186457
|
186608
|
186609
|
186610