<html><body>
<p><font size="2" face="sans-serif">Hi Alfredo,</font><br>
<br>
<font size="2" face="sans-serif">another way, instead of validating, is to transcribe the filenames. We extended the sanitise subroutine in perl_lib/EPrints/System.pm like this:</font><br>
<br>
<font size="2" face="Menlo-Regular">Index: System.pm</font><br>
<font size="2" face="Menlo-Regular">===================================================================</font><br>
<font size="2" face="Menlo-Regular">--- System.pm        (revision 1405)</font><br>
<font size="2" face="Menlo-Regular">+++ System.pm        (revision 1406)</font><br>
<font size="2" face="Menlo-Regular">@@ -25,6 +25,7 @@</font><br>
<font size="2" face="Menlo-Regular"> use strict;</font><br>
<font size="2" face="Menlo-Regular"> use </font><a href="File://:Copy"><font size="2" face="Menlo-Regular">File::Copy</font></a><font size="2" face="Menlo-Regular">;</font><br>
<font size="2" face="Menlo-Regular"> use Digest::MD5;</font><br>
<font size="2" face="Menlo-Regular">+use Text::Unidecode;</font><br>
<font size="2" face="Menlo-Regular"> </font><br>
<font size="2" face="Menlo-Regular"> =item $sys = EPrints::System->new();</font><br>
<font size="2" face="Menlo-Regular"> </font><br>
<font size="2" face="Menlo-Regular">@@ -540,6 +541,10 @@</font><br>
<font size="2" face="Menlo-Regular">         $filepath = Encode::decode_utf8( $filepath )</font><br>
<font size="2" face="Menlo-Regular">                 if !utf8::is_utf8( $filepath );</font><br>
<font size="2" face="Menlo-Regular"> </font><br>
<font size="2" face="Menlo-Regular">+        # UZH CHANGE ZORA-542 2016/12/21/mb</font><br>
<font size="2" face="Menlo-Regular">+         $filepath = unidecode( $filepath );</font><br>
<font size="2" face="Menlo-Regular">+        $filepath =~ s![\x20]!_!g;</font><br>
<font size="2" face="Menlo-Regular">+</font><br>
<font size="2" face="Menlo-Regular">         # control characters + Win32 restricted</font><br>
<font size="2" face="Menlo-Regular">         $filepath =~ s![\x00-\x0f\x7f<>:"\\|?*]!_!g;</font><br>
<br>
<br>
<br>
<font size="2" face="sans-serif">Best regards,</font><br>
<br>
<font size="2" face="sans-serif">Martin</font><br>
<br>
<font size="2" face="sans-serif">--</font><br>
<font size="2" face="sans-serif">Dr. Martin Brändle</font><br>
<font size="2" face="sans-serif">Zentrale Informatik</font><br>
<font size="2" face="sans-serif">Universität Zürich</font><br>
<font size="2" face="sans-serif">Stampfenbachstr. 73</font><br>
<font size="2" face="sans-serif">CH-8006 Zürich</font><br>
<br>
<font size="2" face="sans-serif">mail: martin.braendle@id.uzh.ch</font><br>
<font size="2" face="sans-serif">phone: +41 44 63 56705</font><br>
<font size="2" face="sans-serif">fax: +41 44 63 54505</font><br>
<font size="2" face="sans-serif"><a href="http://www.zi.uzh.ch">http://www.zi.uzh.ch</a></font><br>
<br>
<img width="16" height="16" src="cid:1__=4EBB0B7BDFDFB1B98f9e8a93df9@lotus.uzh.ch" border="0" alt="Inactive hide details for th.lauke---30.11.2017 13:52:25---Hi Alfredo, we solved an similar feature request by a either reposit"><font size="2" color="#424282" face="sans-serif">th.lauke---30.11.2017 13:52:25---Hi Alfredo, we solved an similar feature request by a either repository specific (i.e. Eprints/archi</font><br>
<br>
<font size="1" color="#5F5F5F" face="sans-serif">Von:        </font><font size="1" face="sans-serif">th.lauke@arcor.de</font><br>
<font size="1" color="#5F5F5F" face="sans-serif">An:        </font><font size="1" face="sans-serif">eprints-tech@ecs.soton.ac.uk</font><br>
<font size="1" color="#5F5F5F" face="sans-serif">Datum:        </font><font size="1" face="sans-serif">30.11.2017 13:52</font><br>
<font size="1" color="#5F5F5F" face="sans-serif">Betreff:        </font><font size="1" face="sans-serif">Re: [EP-tech] validation on upload field</font><br>
<font size="1" color="#5F5F5F" face="sans-serif">Gesendet von:        </font><font size="1" face="sans-serif">eprints-tech-bounces@ecs.soton.ac.uk</font><br>
<hr width="100%" size="2" align="left" noshade style="color:#8091A5; "><br>
<br>
<br>
<tt><font size="2">Hi Alfredo,<br>
<br>
we solved an similar feature request by a either repository specific (i.e. Eprints/archives/repoID/cfg/cfg.d/) or server specific (i.e. Eprints/site_lib/cfg.d/) document_validate.pl:<br>
<br>
$c->{validate_document} = sub<br>
{<br>
my( $document, $repository, $for_archive ) = @_;<br>
<br>
my @problems = ();<br>
<br>
my $xml = $repository->xml();<br>
<br>
# default checks<br>
# :<br>
# site-specific checks<br>
<br>
# check for proper filename, i.e. accepted by tivoli backup ingesting only ASCI-filenames without blanks<br>
# print STDERR "main: ", $document->value( "main" )," escaped: ",URI::Escape::uri_escape_utf8($document->value( "main" ), "^A-Za-z0-9\-\._~\/");<br>
my $doc_name_uri = URI::Escape::uri_escape_utf8($document->value( "main" ), "^A-Za-z0-9\-\._~\/");<br>
if( $document->value( "main" ) ne $doc_name_uri )<br>
{<br>
my $fieldname = $repository->make_element( "span", class=>"ep_problem_field:documents" );<br>
$fieldname->appendChild( $document->dataset->render_name( $repository ) );<br>
<br>
my $prob = $repository->make_doc_fragment;<br>
$prob->appendChild( $repository->html_phrase( "validate:bad_filename", fieldname=>$fieldname ) );<br>
$prob->appendChild( $repository->make_text( $doc_name_uri ) );<br>
<br>
$prob->appendChild( $repository->html_phrase( "validate:original_filename") );<br>
$prob->appendChild( $repository->make_text( $document->value( "main" ) ) );<br>
<br>
push @problems, $prob;<br>
}<br>
<br>
<br>
return( @problems );<br>
};<br>
<br>
After setting the introduced phrases by<br>
<epp:phrase id="validate:bad_filename">Please replace non-ASCII characters (e.g. 'äöü') or blanks in the name of uploaded <epc:pin name="fieldname" /> appropriately to simplify future handling!<br/>Following filename prepared for repository<br/></epp:phrase><br>
<epp:phrase id="validate:original_filename"><br/>is different to original one :(<br/></epp:phrase><br>
in an appropriate .../lang/en/phrases/... file it should work :-)<br>
<br>
Hth<br>
Thomas<br>
<br>
*** Options: </font></tt><tt><font size="2"><a href="http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech">http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech</a></font></tt><tt><font size="2"><br>
*** Archive: </font></tt><tt><font size="2"><a href="http://www.eprints.org/tech.php/">http://www.eprints.org/tech.php/</a></font></tt><tt><font size="2"><br>
*** EPrints community wiki: </font></tt><tt><font size="2"><a href="http://wiki.eprints.org/">http://wiki.eprints.org/</a></font></tt><tt><font size="2"><br>
*** EPrints developers Forum: </font></tt><tt><font size="2"><a href="http://forum.eprints.org/">http://forum.eprints.org/</a></font></tt><tt><font size="2"><br>
</font></tt><br>
<br>
</body></html>