Bug 21142: Open uploaded files in utf-8 - batch mod/del
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 17 Aug 2018 15:07:55 +0000 (12:07 -0300)
committerNick Clemens <nick@bywatersolutions.com>
Tue, 21 Aug 2018 11:45:19 +0000 (11:45 +0000)
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 <oleonard@myacpl.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

tools/batchMod.pl
tools/batch_delete_records.pl
tools/batch_record_modification.pl

index 0e985a2..503f5ce 100755 (executable)
@@ -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;
index 8804e62..149b44d 100755 (executable)
@@ -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]*$//;
index bfdb758..2b76084 100755 (executable)
@@ -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]*$//;