<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Menlo-Regular;
        panose-1:0 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
tt
        {mso-style-priority:99;
        font-family:"Courier New";}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-GB" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">In GitHub, there is this:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><a href="https://github.com/eprints/eprints/blob/3.3/lib/defaultcfg/cfg.d/optional_filename_sanitise.pl">https://github.com/eprints/eprints/blob/3.3/lib/defaultcfg/cfg.d/optional_filename_sanitise.pl</a><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">which works alongside an addition to System.pm:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><a href="https://github.com/eprints/eprints/blob/69f4c9e581df137b970ce0ab4e08572976162411/perl_lib/EPrints/System.pm#L551-L559">https://github.com/eprints/eprints/blob/69f4c9e581df137b970ce0ab4e08572976162411/perl_lib/EPrints/System.pm#L551-L559</a><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">That might be useful to know about?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">Cheers,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">John<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif"> eprints-tech-bounces@ecs.soton.ac.uk [mailto:eprints-tech-bounces@ecs.soton.ac.uk]
<b>On Behalf Of </b>martin.braendle@id.uzh.ch<br>
<b>Sent:</b> 30 November 2017 13:56<br>
<b>To:</b> eprints-tech@ecs.soton.ac.uk<br>
<b>Subject:</b> [EP-tech] Antwort: Re: validation on upload field<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p><span style="font-size:10.0pt;font-family:"Arial",sans-serif">Hi Alfredo,</span><br>
<br>
<span style="font-size:10.0pt;font-family:"Arial",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:</span><br>
<br>
<span style="font-size:10.0pt;font-family:"Menlo-Regular",serif">Index: System.pm</span><br>
<span style="font-size:10.0pt;font-family:"Menlo-Regular",serif">===================================================================</span><br>
<span style="font-size:10.0pt;font-family:"Menlo-Regular",serif">--- System.pm (revision 1405)</span><br>
<span style="font-size:10.0pt;font-family:"Menlo-Regular",serif">+++ System.pm (revision 1406)</span><br>
<span style="font-size:10.0pt;font-family:"Menlo-Regular",serif">@@ -25,6 +25,7 @@</span><br>
<span style="font-size:10.0pt;font-family:"Menlo-Regular",serif"> use strict;</span><br>
<span style="font-size:10.0pt;font-family:"Menlo-Regular",serif"> use </span><a href="File:///\\:Copy"><span style="font-size:10.0pt;font-family:"Menlo-Regular",serif">File::Copy</span></a><span style="font-size:10.0pt;font-family:"Menlo-Regular",serif">;</span><br>
<span style="font-size:10.0pt;font-family:"Menlo-Regular",serif"> use Digest::MD5;</span><br>
<span style="font-size:10.0pt;font-family:"Menlo-Regular",serif">+use Text::Unidecode;</span><br>
<span style="font-size:10.0pt;font-family:"Menlo-Regular",serif"> </span><br>
<span style="font-size:10.0pt;font-family:"Menlo-Regular",serif"> =item $sys = EPrints::System->new();</span><br>
<span style="font-size:10.0pt;font-family:"Menlo-Regular",serif"> </span><br>
<span style="font-size:10.0pt;font-family:"Menlo-Regular",serif">@@ -540,6 +541,10 @@</span><br>
<span style="font-size:10.0pt;font-family:"Menlo-Regular",serif"> $filepath = Encode::decode_utf8( $filepath )</span><br>
<span style="font-size:10.0pt;font-family:"Menlo-Regular",serif"> if !utf8::is_utf8( $filepath );</span><br>
<span style="font-size:10.0pt;font-family:"Menlo-Regular",serif"> </span><br>
<span style="font-size:10.0pt;font-family:"Menlo-Regular",serif">+ # UZH CHANGE ZORA-542 2016/12/21/mb</span><br>
<span style="font-size:10.0pt;font-family:"Menlo-Regular",serif">+ $filepath = unidecode( $filepath );</span><br>
<span style="font-size:10.0pt;font-family:"Menlo-Regular",serif">+ $filepath =~ s![\x20]!_!g;</span><br>
<span style="font-size:10.0pt;font-family:"Menlo-Regular",serif">+</span><br>
<span style="font-size:10.0pt;font-family:"Menlo-Regular",serif"> # control characters + Win32 restricted</span><br>
<span style="font-size:10.0pt;font-family:"Menlo-Regular",serif"> $filepath =~ s![\x00-\x0f\x7f<>:"\\|?*]!_!g;</span><br>
<br>
<br>
<br>
<span style="font-size:10.0pt;font-family:"Arial",sans-serif">Best regards,</span><br>
<br>
<span style="font-size:10.0pt;font-family:"Arial",sans-serif">Martin</span><br>
<br>
<span style="font-size:10.0pt;font-family:"Arial",sans-serif">--</span><br>
<span style="font-size:10.0pt;font-family:"Arial",sans-serif">Dr. Martin Brändle</span><br>
<span style="font-size:10.0pt;font-family:"Arial",sans-serif">Zentrale Informatik</span><br>
<span style="font-size:10.0pt;font-family:"Arial",sans-serif">Universität Zürich</span><br>
<span style="font-size:10.0pt;font-family:"Arial",sans-serif">Stampfenbachstr. 73</span><br>
<span style="font-size:10.0pt;font-family:"Arial",sans-serif">CH-8006 Zürich</span><br>
<br>
<span style="font-size:10.0pt;font-family:"Arial",sans-serif">mail: martin.braendle@id.uzh.ch</span><br>
<span style="font-size:10.0pt;font-family:"Arial",sans-serif">phone: +41 44 63 56705</span><br>
<span style="font-size:10.0pt;font-family:"Arial",sans-serif">fax: +41 44 63 54505</span><br>
<span style="font-size:10.0pt;font-family:"Arial",sans-serif"><a href="http://www.zi.uzh.ch">http://www.zi.uzh.ch</a></span><br>
<br>
<img border="0" width="16" height="16" id="_x0000_i1025" src="cid:image001.gif@01D369F2.0697A540" 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"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#424282">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</span><br>
<br>
<span style="font-size:7.5pt;font-family:"Arial",sans-serif;color:#5F5F5F">Von: </span>
<span style="font-size:7.5pt;font-family:"Arial",sans-serif">th.lauke@arcor.de</span><br>
<span style="font-size:7.5pt;font-family:"Arial",sans-serif;color:#5F5F5F">An: </span>
<span style="font-size:7.5pt;font-family:"Arial",sans-serif">eprints-tech@ecs.soton.ac.uk</span><br>
<span style="font-size:7.5pt;font-family:"Arial",sans-serif;color:#5F5F5F">Datum:
</span><span style="font-size:7.5pt;font-family:"Arial",sans-serif">30.11.2017 13:52</span><br>
<span style="font-size:7.5pt;font-family:"Arial",sans-serif;color:#5F5F5F">Betreff:
</span><span style="font-size:7.5pt;font-family:"Arial",sans-serif">Re: [EP-tech] validation on upload field</span><br>
<span style="font-size:7.5pt;font-family:"Arial",sans-serif;color:#5F5F5F">Gesendet von:
</span><span style="font-size:7.5pt;font-family:"Arial",sans-serif">eprints-tech-bounces@ecs.soton.ac.uk</span><o:p></o:p></p>
<div class="MsoNormal">
<hr size="2" width="100%" noshade="" style="color:#8091A5" align="left">
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
<br>
<br>
<tt><span style="font-size:10.0pt">Hi Alfredo,</span></tt><span style="font-size:10.0pt;font-family:"Courier New""><br>
<br>
<tt>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:</tt><br>
<br>
<tt>$c->{validate_document} = sub</tt><br>
<tt>{</tt><br>
<tt> my( $document, $repository, $for_archive ) = @_;</tt><br>
<br>
<tt> my @problems = ();</tt><br>
<br>
<tt> my $xml = $repository->xml();</tt><br>
<br>
<tt> # default checks</tt><br>
<tt># :</tt><br>
<tt> # site-specific checks</tt><br>
<br>
<tt> # check for proper filename, i.e. accepted by tivoli backup ingesting only ASCI-filenames without blanks</tt><br>
<tt> # print STDERR "main: ", $document->value( "main" )," escaped: ",URI::Escape::uri_escape_utf8($document->value( "main" ), "^A-Za-z0-9\-\._~\/");</tt><br>
<tt> my $doc_name_uri = URI::Escape::uri_escape_utf8($document->value( "main" ), "^A-Za-z0-9\-\._~\/");</tt><br>
<tt> if( $document->value( "main" ) ne $doc_name_uri )</tt><br>
<tt> {</tt><br>
<tt> my $fieldname = $repository->make_element( "span", class=>"ep_problem_field:documents" );</tt><br>
<tt> $fieldname->appendChild( $document->dataset->render_name( $repository ) );</tt><br>
<br>
<tt> my $prob = $repository->make_doc_fragment;</tt><br>
<tt> $prob->appendChild( $repository->html_phrase( "validate:bad_filename", fieldname=>$fieldname ) );</tt><br>
<tt> $prob->appendChild( $repository->make_text( $doc_name_uri ) );</tt><br>
<br>
<tt> $prob->appendChild( $repository->html_phrase( "validate:original_filename") );</tt><br>
<tt> $prob->appendChild( $repository->make_text( $document->value( "main" ) ) );</tt><br>
<br>
<tt> push @problems, $prob;</tt><br>
<tt> }</tt><br>
<br>
<br>
<tt> return( @problems );</tt><br>
<tt>};</tt><br>
<br>
<tt>After setting the introduced phrases by</tt><br>
<tt><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></tt><br>
<tt><epp:phrase id="validate:original_filename"><br/>is different to original one :(<br/></epp:phrase></tt><br>
<tt>in an appropriate .../lang/en/phrases/... file it should work :-)</tt><br>
<br>
<tt>Hth</tt><br>
<tt>Thomas</tt><br>
<br>
<tt>*** Options: <a href="http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech">
http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech</a></tt><br>
<tt>*** Archive: <a href="http://www.eprints.org/tech.php/">http://www.eprints.org/tech.php/</a></tt><br>
<tt>*** EPrints community wiki: <a href="http://wiki.eprints.org/">http://wiki.eprints.org/</a></tt><br>
<tt>*** EPrints developers Forum: <a href="http://forum.eprints.org/">http://forum.eprints.org/</a></tt><br>
<br>
</span><o:p></o:p></p>
</div>
</body>
</html>