<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:&quot;Calibri&quot;,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:&quot;Calibri&quot;,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:&quot;Calibri&quot;,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:&quot;Calibri&quot;,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:&quot;Calibri&quot;,sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,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:&quot;Calibri&quot;,sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,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:&quot;Calibri&quot;,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:&quot;Calibri&quot;,sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p>&nbsp;</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:&quot;Calibri&quot;,sans-serif">From:</span></b><span lang="EN-US" style="font-size:11.0pt;font-family:&quot;Calibri&quot;,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>&nbsp;</o:p></p>
<p><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif">Hi Alfredo,</span><br>
<br>
<span style="font-size:10.0pt;font-family:&quot;Arial&quot;,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:&quot;Menlo-Regular&quot;,serif">Index: System.pm</span><br>
<span style="font-size:10.0pt;font-family:&quot;Menlo-Regular&quot;,serif">===================================================================</span><br>
<span style="font-size:10.0pt;font-family:&quot;Menlo-Regular&quot;,serif">--- System.pm (revision 1405)</span><br>
<span style="font-size:10.0pt;font-family:&quot;Menlo-Regular&quot;,serif">&#43;&#43;&#43; System.pm (revision 1406)</span><br>
<span style="font-size:10.0pt;font-family:&quot;Menlo-Regular&quot;,serif">@@ -25,6 &#43;25,7 @@</span><br>
<span style="font-size:10.0pt;font-family:&quot;Menlo-Regular&quot;,serif">&nbsp;use strict;</span><br>
<span style="font-size:10.0pt;font-family:&quot;Menlo-Regular&quot;,serif">&nbsp;use </span><a href="File:///\\:Copy"><span style="font-size:10.0pt;font-family:&quot;Menlo-Regular&quot;,serif">File::Copy</span></a><span style="font-size:10.0pt;font-family:&quot;Menlo-Regular&quot;,serif">;</span><br>
<span style="font-size:10.0pt;font-family:&quot;Menlo-Regular&quot;,serif">&nbsp;use Digest::MD5;</span><br>
<span style="font-size:10.0pt;font-family:&quot;Menlo-Regular&quot;,serif">&#43;use Text::Unidecode;</span><br>
<span style="font-size:10.0pt;font-family:&quot;Menlo-Regular&quot;,serif">&nbsp;</span><br>
<span style="font-size:10.0pt;font-family:&quot;Menlo-Regular&quot;,serif">&nbsp;=item $sys = EPrints::System-&gt;new();</span><br>
<span style="font-size:10.0pt;font-family:&quot;Menlo-Regular&quot;,serif">&nbsp;</span><br>
<span style="font-size:10.0pt;font-family:&quot;Menlo-Regular&quot;,serif">@@ -540,6 &#43;541,10 @@</span><br>
<span style="font-size:10.0pt;font-family:&quot;Menlo-Regular&quot;,serif">&nbsp; $filepath = Encode::decode_utf8( $filepath )</span><br>
<span style="font-size:10.0pt;font-family:&quot;Menlo-Regular&quot;,serif">&nbsp; if !utf8::is_utf8( $filepath );</span><br>
<span style="font-size:10.0pt;font-family:&quot;Menlo-Regular&quot;,serif">&nbsp;</span><br>
<span style="font-size:10.0pt;font-family:&quot;Menlo-Regular&quot;,serif">&#43; # UZH CHANGE ZORA-542 2016/12/21/mb</span><br>
<span style="font-size:10.0pt;font-family:&quot;Menlo-Regular&quot;,serif">&#43; $filepath = unidecode( $filepath );</span><br>
<span style="font-size:10.0pt;font-family:&quot;Menlo-Regular&quot;,serif">&#43; $filepath =~ s![\x20]!_!g;</span><br>
<span style="font-size:10.0pt;font-family:&quot;Menlo-Regular&quot;,serif">&#43;</span><br>
<span style="font-size:10.0pt;font-family:&quot;Menlo-Regular&quot;,serif">&nbsp; # control characters &#43; Win32 restricted</span><br>
<span style="font-size:10.0pt;font-family:&quot;Menlo-Regular&quot;,serif">&nbsp; $filepath =~ s![\x00-\x0f\x7f&lt;&gt;:&quot;\\|?*]!_!g;</span><br>
<br>
<br>
<br>
<span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif">Best regards,</span><br>
<br>
<span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif">Martin</span><br>
<br>
<span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif">--</span><br>
<span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif">Dr. Martin Brändle</span><br>
<span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif">Zentrale Informatik</span><br>
<span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif">Universität Zürich</span><br>
<span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif">Stampfenbachstr. 73</span><br>
<span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif">CH-8006 Zürich</span><br>
<br>
<span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif">mail: martin.braendle@id.uzh.ch</span><br>
<span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif">phone: &#43;41 44 63 56705</span><br>
<span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif">fax: &#43;41 44 63 54505</span><br>
<span style="font-size:10.0pt;font-family:&quot;Arial&quot;,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:&quot;Arial&quot;,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:&quot;Arial&quot;,sans-serif;color:#5F5F5F">Von: </span>
<span style="font-size:7.5pt;font-family:&quot;Arial&quot;,sans-serif">th.lauke@arcor.de</span><br>
<span style="font-size:7.5pt;font-family:&quot;Arial&quot;,sans-serif;color:#5F5F5F">An: </span>
<span style="font-size:7.5pt;font-family:&quot;Arial&quot;,sans-serif">eprints-tech@ecs.soton.ac.uk</span><br>
<span style="font-size:7.5pt;font-family:&quot;Arial&quot;,sans-serif;color:#5F5F5F">Datum:
</span><span style="font-size:7.5pt;font-family:&quot;Arial&quot;,sans-serif">30.11.2017 13:52</span><br>
<span style="font-size:7.5pt;font-family:&quot;Arial&quot;,sans-serif;color:#5F5F5F">Betreff:
</span><span style="font-size:7.5pt;font-family:&quot;Arial&quot;,sans-serif">Re: [EP-tech] validation on upload field</span><br>
<span style="font-size:7.5pt;font-family:&quot;Arial&quot;,sans-serif;color:#5F5F5F">Gesendet von:
</span><span style="font-size:7.5pt;font-family:&quot;Arial&quot;,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:&quot;Courier New&quot;"><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-&gt;{validate_document} = sub</tt><br>
<tt>{</tt><br>
<tt>&nbsp; &nbsp; &nbsp; &nbsp;my( $document, $repository, $for_archive ) = @_;</tt><br>
<br>
<tt>&nbsp; &nbsp; &nbsp; &nbsp;my @problems = ();</tt><br>
<br>
<tt>&nbsp; &nbsp; &nbsp; &nbsp;my $xml = $repository-&gt;xml();</tt><br>
<br>
<tt>&nbsp; &nbsp; &nbsp; &nbsp;# default checks</tt><br>
<tt># :</tt><br>
<tt>&nbsp; &nbsp; &nbsp; &nbsp;# site-specific checks</tt><br>
<br>
<tt>&nbsp; &nbsp; &nbsp; &nbsp;# check for proper filename, i.e. accepted by tivoli backup ingesting only ASCI-filenames without blanks</tt><br>
<tt>&nbsp; &nbsp; &nbsp; &nbsp;# print STDERR &quot;main: &quot;, $document-&gt;value( &quot;main&quot; ),&quot; escaped: &quot;,URI::Escape::uri_escape_utf8($document-&gt;value( &quot;main&quot; ), &quot;^A-Za-z0-9\-\._~\/&quot;);</tt><br>
<tt>&nbsp; &nbsp; &nbsp; &nbsp;my $doc_name_uri = URI::Escape::uri_escape_utf8($document-&gt;value( &quot;main&quot; ), &quot;^A-Za-z0-9\-\._~\/&quot;);</tt><br>
<tt>&nbsp; &nbsp; &nbsp; &nbsp;if( $document-&gt;value( &quot;main&quot; ) ne $doc_name_uri )</tt><br>
<tt>&nbsp; &nbsp; &nbsp; &nbsp;{</tt><br>
<tt>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;my $fieldname = $repository-&gt;make_element( &quot;span&quot;, class=&gt;&quot;ep_problem_field:documents&quot; );</tt><br>
<tt>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$fieldname-&gt;appendChild( $document-&gt;dataset-&gt;render_name( $repository ) );</tt><br>
<br>
<tt>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;my $prob = $repository-&gt;make_doc_fragment;</tt><br>
<tt>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$prob-&gt;appendChild( $repository-&gt;html_phrase( &quot;validate:bad_filename&quot;, fieldname=&gt;$fieldname ) );</tt><br>
<tt>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$prob-&gt;appendChild( $repository-&gt;make_text( $doc_name_uri ) );</tt><br>
<br>
<tt>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$prob-&gt;appendChild( $repository-&gt;html_phrase( &quot;validate:original_filename&quot;) );</tt><br>
<tt>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$prob-&gt;appendChild( $repository-&gt;make_text( $document-&gt;value( &quot;main&quot; ) ) );</tt><br>
<br>
<tt>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;push @problems, $prob;</tt><br>
<tt>&nbsp; &nbsp; &nbsp; &nbsp;}</tt><br>
<br>
<br>
<tt>&nbsp; &nbsp; &nbsp; &nbsp;return( @problems );</tt><br>
<tt>};</tt><br>
<br>
<tt>After setting the introduced phrases by</tt><br>
<tt>&lt;epp:phrase id=&quot;validate:bad_filename&quot;&gt;Please replace non-ASCII characters (e.g. 'äöü') or blanks in the name of uploaded &lt;epc:pin name=&quot;fieldname&quot; /&gt; appropriately to simplify future handling!&lt;br/&gt;Following filename prepared for repository&lt;br/&gt;&lt;/epp:phrase&gt;</tt><br>
<tt>&lt;epp:phrase id=&quot;validate:original_filename&quot;&gt;&lt;br/&gt;is different to original one :(&lt;br/&gt;&lt;/epp:phrase&gt;</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>