Bugzilla – Attachment 74119 Details for
Bug 11317
Add a way to access files from the intranet
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11317: Make filename unicode-proof, renamed accessdir to access_dir and fix db update
Bug-11317-Make-filename-unicode-proof-renamed-acce.patch (text/plain), 7.07 KB, created by
Roch D'Amour
on 2018-04-12 19:42:39 UTC
(
hide
)
Description:
Bug 11317: Make filename unicode-proof, renamed accessdir to access_dir and fix db update
Filename:
MIME Type:
Creator:
Roch D'Amour
Created:
2018-04-12 19:42:39 UTC
Size:
7.07 KB
patch
obsolete
>From 8dd1b65ec6c14997027726371cb12e8874ef1704 Mon Sep 17 00:00:00 2001 >From: Roch D'Amour <roch.damour@inlibro.com> >Date: Thu, 12 Apr 2018 14:53:29 -0400 >Subject: [PATCH] Bug 11317: Make filename unicode-proof, renamed accessdir to > access_dir and fix db update >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This patch does many small things : >- Added "INSERT IGNORE" in the atomic update >- Renamed accessdir to access_dir >- Now decode the filename to utf8 to make sure the stat() method point at it. > >Test plan: >1. Define <access_dir>/tmp/koha-public</access_dir> in your koha_conf >2. change dir to /tmp/koha-public >3. create a file with a normal name, i.e. echo "bonjour koha" > testfile.txt >4. create a file with a name containing a unicode character, i.e. touch hiâ¤.txt >5. Go in the "Reports" section in the intranet and select "Report/log files" >6. Verify that the filename "hiâ¤.txt" looks fine >7. Click on the "testfile.txt" file, a download dialog should appear. >8. Download the file and verify its content. It should contain the text "bonjour koha". > >Sponsored by : CCSR >--- > debian/templates/koha-conf-site.xml.in | 2 +- > etc/koha-conf.xml | 2 +- > .../bz11317-add-permission-for-tools-access-file.sql | 2 +- > .../prog/en/modules/tools/access_files.tt | 4 ++-- > tools/access_files.pl | 20 ++++++++++++-------- > 5 files changed, 17 insertions(+), 13 deletions(-) > >diff --git a/debian/templates/koha-conf-site.xml.in b/debian/templates/koha-conf-site.xml.in >index 01d8f07..e0bfd00 100644 >--- a/debian/templates/koha-conf-site.xml.in >+++ b/debian/templates/koha-conf-site.xml.in >@@ -297,7 +297,7 @@ __END_SRU_PUBLICSERVER__ > <api_secret_passphrase>__API_SECRET__</api_secret_passphrase> > > <!-- Accessible directory from the staff client, uncomment the following line and define a valid path to let the intranet user access it--> >- <!-- <accessdir></accessdir> --> >+ <!-- <access_dir></access_dir> --> > > <!-- true type font mapping according to type from $font_types in C4/Creators/Lib.pm --> > <ttf> >diff --git a/etc/koha-conf.xml b/etc/koha-conf.xml >index c06b5ae..f4c8198 100644 >--- a/etc/koha-conf.xml >+++ b/etc/koha-conf.xml >@@ -128,7 +128,7 @@ __PAZPAR2_TOGGLE_XML_POST__ > <api_secret_passphrase>CHANGEME</api_secret_passphrase> > > <!-- Accessible directory from the staff client, uncomment the following line and define a valid path to let the intranet user access it--> >- <!-- <accessdir></accessdir> --> >+ <!-- <access_dir></access_dir> --> > > <!-- true type font mapping accoding to type from $font_types in C4/Creators/Lib.pm --> > <ttf> >diff --git a/installer/data/mysql/atomicupdate/bz11317-add-permission-for-tools-access-file.sql b/installer/data/mysql/atomicupdate/bz11317-add-permission-for-tools-access-file.sql >index dc49a78..8861378 100644 >--- a/installer/data/mysql/atomicupdate/bz11317-add-permission-for-tools-access-file.sql >+++ b/installer/data/mysql/atomicupdate/bz11317-add-permission-for-tools-access-file.sql >@@ -1 +1 @@ >-INSERT INTO permissions (module_bit, code, description) VALUES (13, 'access_files', 'Access to the files stored on the server'); >+INSERT IGNORE INTO permissions (module_bit, code, description) VALUES (13, 'access_files', 'Access to the files stored on the server'); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/access_files.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/access_files.tt >index 4999565..3619d7c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/access_files.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/access_files.tt >@@ -19,7 +19,7 @@ > <h1>Report/log files</h1> > > [% IF ( error_no_dir ) %] >- <div class="dialog alert"><strong>Error : </strong>Report/log files could not be found because the "accessdir" option was not set in "koha-conf.xml". Contact your system administrator to add this option.</div> >+ <div class="dialog alert"><strong>Error : </strong>Report/log files could not be found because the "access_dir" option was not set in "koha-conf.xml". Contact your system administrator to add this option.</div> > [% ELSE %] > [% IF ( files_loop ) %] > <table id="files"> >@@ -64,4 +64,4 @@ > }); > //]]> > </script> >-[% INCLUDE 'intranet-bottom.inc' %] >\ No newline at end of file >+[% INCLUDE 'intranet-bottom.inc' %] >diff --git a/tools/access_files.pl b/tools/access_files.pl >index 61b3abe..4f58123 100755 >--- a/tools/access_files.pl >+++ b/tools/access_files.pl >@@ -3,7 +3,7 @@ > # Frédérick Capovilla, 2011 - Libéo > # > # Show a list of all the files in the directory specified by the option >-# "accessdir" in koha-conf.xml so they can be downloaded by users with the >+# "access_dir" in koha-conf.xml so they can be downloaded by users with the > # "access_files" permission. > # > # This file is part of Koha. >@@ -30,11 +30,12 @@ use C4::Output; > use C4::Koha; > use File::stat qw(stat); > use Digest::MD5 qw(md5_hex); >+use Encode; > > my $input = new CGI; > my $file_id = $input->param("id"); >-my $accessdir = C4::Context->config('accessdir'); >-my @directories = $accessdir ? (ref $accessdir ? @{$accessdir} : ($accessdir)) : (); >+my $access_dir = C4::Context->config('access_dir'); >+my @directories = $access_dir ? (ref $access_dir ? @{$access_dir} : ($access_dir)) : (); > > my ($template, $borrowernumber, $cookie) > = get_template_and_user({template_name => "tools/access_files.tt", >@@ -54,10 +55,13 @@ else { > opendir(DIR, $dir); > foreach my $filename (readdir(DIR)) { > my $full_path = "$dir/$filename"; >- my $id = md5_hex($full_path); >+ my $id = md5_hex($full_path); > next if ($filename =~ /^\./ or -d $full_path); > >- my $st = stat($full_path); >+ # Make sure the filename is unicode-friendly >+ my $decoded_filename = decode('utf8', $filename); >+ my $st = stat("$dir/$decoded_filename"); >+ > my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =localtime($st->mtime); > my $dt=DateTime->new(year => $year + 1900, > month => $mon + 1, >@@ -65,8 +69,8 @@ else { > hour => $hour, > minute => $min, > ); >- push(@files_list, {name => $filename, >- accessdir => $dir, >+ push(@files_list, {name => $decoded_filename, >+ access_dir => $dir, > date =>Koha::DateUtils::output_pref($dt), > size => $st->size, > id => $id}); >@@ -78,7 +82,7 @@ else { > # If we received a file_id and it is valid, send the file to the browser > if(defined $file_id and exists $files_hash{$file_id} ){ > my $filename = $files_hash{$file_id}->{name}; >- my $dir = $files_hash{$file_id}->{accessdir}; >+ my $dir = $files_hash{$file_id}->{access_dir}; > binmode STDOUT; > # Open the selected file and send it to the browser > print $input->header(-type => 'application/x-download', >-- >2.7.4
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 11317
:
23203
|
25387
|
27492
|
27579
|
27604
|
35938
|
35939
|
35940
|
36844
|
39783
|
39784
|
39785
|
39786
|
44859
|
44860
|
48629
|
48635
|
49941
|
49942
|
49943
|
49944
|
49945
|
49946
|
49947
|
50421
|
50424
|
50425
|
50440
|
53446
|
58220
|
58221
|
58222
|
58223
|
58224
|
58225
|
58226
|
62971
|
62972
|
62973
|
62974
|
62975
|
64088
|
64089
|
65691
|
65851
|
65855
|
65856
|
65857
|
65909
|
65910
|
65911
|
65912
|
65913
|
65914
|
65915
|
65918
|
66091
|
66092
|
66093
|
66094
|
66095
|
66096
|
66097
|
66098
|
66099
|
66100
|
72097
|
72309
|
72456
|
72457
|
72458
|
72459
|
72460
|
72461
|
72462
|
72463
|
72464
|
72465
|
74119
|
74379
|
74756
|
74911
|
74912
|
74916
|
74917
|
74918
|
74919
|
75019