From 34b585b7e162e2c6bece9d176dfc6f27bb8e24ac Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 17 Aug 2018 12:07:55 -0300 Subject: [PATCH] Bug 21142: Open uploaded files in utf-8 - batch mod/del MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Batch item/record modification/deletion tools does not open uploaded files in utf-8 Test plan: Edit and delete records and items using a file which will contain: valid and invalid barcodes with and without utf-8 chars (💕) You should see the warning message: "The *** 39999000💕001679 does not exist in the database." Signed-off-by: Owen Leonard --- tools/batchMod.pl | 1 + tools/batch_delete_records.pl | 1 + tools/batch_record_modification.pl | 1 + 3 files changed, 3 insertions(+) diff --git a/tools/batchMod.pl b/tools/batchMod.pl index 0e985a2..503f5ce 100755 --- a/tools/batchMod.pl +++ b/tools/batchMod.pl @@ -237,6 +237,7 @@ if ($op eq "show"){ my @contentlist; if ($filefh){ + binmode $filefh, ':encoding(UTF-8)'; while (my $content=<$filefh>){ $content =~ s/[\r\n]*$//; push @contentlist, $content if $content; diff --git a/tools/batch_delete_records.pl b/tools/batch_delete_records.pl index 8804e62..149b44d 100755 --- a/tools/batch_delete_records.pl +++ b/tools/batch_delete_records.pl @@ -57,6 +57,7 @@ if ( $op eq 'form' ) { $recordtype = 'biblio'; } elsif ( my $uploadfile = $input->param('uploadfile') ) { # A file of id is given + binmode $uploadfile, ':encoding(UTF-8)'; while ( my $content = <$uploadfile> ) { next unless $content; $content =~ s/[\r\n]*$//; diff --git a/tools/batch_record_modification.pl b/tools/batch_record_modification.pl index bfdb758..2b76084 100755 --- a/tools/batch_record_modification.pl +++ b/tools/batch_record_modification.pl @@ -105,6 +105,7 @@ if ( $op eq 'form' ) { $recordtype = 'biblio'; } elsif ( my $uploadfile = $input->param('uploadfile') ) { # A file of id is given + binmode $uploadfile, ':encoding(UTF-8)'; while ( my $content = <$uploadfile> ) { next unless $content; $content =~ s/[\r\n]*$//; -- 2.1.4