From 7fd248f3e9c80b36fb451eb90d2c34242c0cbb61 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Thu, 19 Jan 2017 21:13:47 -0500 Subject: [PATCH] Bug 15702: Recommended Counter-patch MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit As per comment #7, this patch affects AddMember and ModMember. The test plan should be the same as comment #6. Secondary patch with tests still to come. Signed-off-by: Marc Véron Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall --- C4/Members.pm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/C4/Members.pm b/C4/Members.pm index ee10cc7fe6..e68a6faecd 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -355,6 +355,14 @@ true on success, or false on failure sub ModMember { my (%data) = @_; + + # trim whitespace from data which has some non-whitespace in it. + foreach my $field_name (keys(%data)) { + if ( defined $data{$field_name} && $data{$field_name} =~ /\S/ ) { + $data{$field_name} =~ s/^\s*|\s*$//g; + } + } + # test to know if you must update or not the borrower password if (exists $data{password}) { if ($data{password} eq '****' or $data{password} eq '') { @@ -442,6 +450,13 @@ sub AddMember { my $dbh = C4::Context->dbh; my $schema = Koha::Database->new()->schema; + # trim whitespace from data which has some non-whitespace in it. + foreach my $field_name (keys(%data)) { + if ( defined $data{$field_name} && $data{$field_name} =~ /\S/ ) { + $data{$field_name} =~ s/^\s*|\s*$//g; + } + } + # generate a proper login if none provided $data{'userid'} = Generate_Userid( $data{'borrowernumber'}, $data{'firstname'}, $data{'surname'} ) if ( $data{'userid'} eq '' || !Check_Userid( $data{'userid'} ) ); -- 2.39.5