Bugzilla – Attachment 127585 Details for
Bug 19318
Add ability to use custom file upload paths
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19318: Normalize uploaded file name
Bug-19318-Normalize-uploaded-file-name.patch (text/plain), 1.95 KB, created by
Julian Maurice
on 2021-11-12 13:39:26 UTC
(
hide
)
Description:
Bug 19318: Normalize uploaded file name
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2021-11-12 13:39:26 UTC
Size:
1.95 KB
patch
obsolete
>From 34b63022429d179b0ec4b93cab1e9257ad7f1167 Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Fri, 12 Nov 2021 14:12:14 +0100 >Subject: [PATCH] Bug 19318: Normalize uploaded file name >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >The uploaded file name can appear in the MARC record (if using the >upload plugin), and all the strings in the MARC record are normalized >using Unicode::Normalize::NFC. >So the file name must be normalized everywhere (in the filesystem and in >the uploaded_files table too). > >Test plan: >1. Create a file whose name contains combining characters. For instance: > echo 'contents' > $(perl -e 'print "cine\x{cc}\x{81}ma"') > > 0xcc 0x81 is utf8 for "Combining acute accent" (Ì ) > https://unicode-table.com/fr/0301/ > Once normalized it should be 0xc3 0xa9 (é) > >2. Use the upload tool to upload this file >3. Verify on your filesystem that the filename is normalized > % ls cin* | xxd > 00000000: 6369 6ec3 a96d 610a cin..ma. > ^^ ^^ >4. If you have configured the storage with a `baseurl`, use the upload > cataloguing plugin, and verify that the generated URL works correctly >--- > Koha/Uploader.pm | 2 ++ > 1 file changed, 2 insertions(+) > >diff --git a/Koha/Uploader.pm b/Koha/Uploader.pm >index 58c2e39b99..7c8b7c0f06 100644 >--- a/Koha/Uploader.pm >+++ b/Koha/Uploader.pm >@@ -67,6 +67,7 @@ use CGI; # no utf8 flag, since it may interfere with binary uploads > use Digest::MD5; > use Encode; > use Time::HiRes; >+use Unicode::Normalize; > > use base qw(Class::Accessor); > >@@ -249,6 +250,7 @@ sub _create_file { > sub _hook { > my ( $self, $filename, $buffer, $bytes_read, $data ) = @_; > $filename= Encode::decode_utf8( $filename ); # UTF8 chars in filename >+ $filename = NFC($filename); > $self->_compute( $filename, $buffer ); > my $fh = $self->_fh( $filename ) // $self->_create_file( $filename ); > print $fh $buffer if $fh; >-- >2.20.1
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 19318
:
71017
|
78620
|
89219
|
118421
|
120101
|
120102
|
127584
|
127585
|
128844
|
128845
|
128846
|
128847
|
133772
|
133773
|
133774
|
133775