From 0d7ba4634ad795703cbb97e371e07ae9252a6c53 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=utf8 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 Signed-off-by: Tomas Cohen Arazi Signed-off-by: Nick Clemens (cherry picked from commit f5f31679bf260d17e996fbe8e2e77f695ac7ddfc) Signed-off-by: Martin Renvoize --- 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 0e985a2c7b..503f5cec63 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 8804e6292a..149b44ddc0 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 bfdb7583f5..2b7608469b 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.39.5