tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Konstantin Kolinko <knst.koli...@gmail.com>
Subject Re: svn commit: r810132 - /tomcat/tc6.0.x/trunk/STATUS.txt
Date Fri, 02 Oct 2009 00:37:48 GMT
I am in favor of using file.toURI().toString(), as proposed by Rainer.

To construct an URL by simply prepending "file:" + several slashes to
the path is simply wrong.

Spaces are not allowed in an URL (see chapter 2.4.3 of RFC2396) and
must be encoded as %20, as well as % symbols in the file name must be
encoded as %25.

The protocol handler for file: protocol unescapes %-encoded symbols
when opening URLConnection to the file, so if the original file name
contained '%' symbol, it should have been escaped.

(sun.net.www.protocol.file.Handler#openConnection(..))

Best regards,
Konstantin Kolinko

2009/9/1 Rainer Jung <rainer.jung@kippdata.de>:
> On 01.09.2009 20:48, Larry Isaacs wrote:
>> Hi Filip,
>>
>> I have a vague recollection about tripping over this issue while working on the Tomcat
support in the Eclipse Web Tools Platform.  WTP has its own version(s) of VirtualWebappLoader,
called WtpWebappLoader, to address it.  If I'm recalling the issue correctly, pre-pending
"file:/" worked on Windows, but not on Linux since an absolute path ended up as "file://somedir/...".
 I believe with the change below, pre-pending "file://" will work for Linux, but not for
Windows, i.e. "file://C:/somedir/..." is going to have problems.  If it helps, I went with
the URL form "file:/somedir/..." and used the following code snippet to get it working for
Windows and Linux in WtpWebappLoader:
>
> Good point.
>
>>
>>             String path = file.getAbsolutePath();
>>             if (path.startsWith("/")) {
>>                 path = "file:" + path;
>>             } else {
>>                 path = "file:/" + path;
>>             }
>>             if (file.isDirectory()) {
>>                 addRepository(path + "/");
>>             } else {
>>                 addRepository(path);
>
> Why not: file.toURI().toString()
>
> It seems this is not cheap, but should handle as much annoyances as
> possible (drive letters, directory trailing slashes, UNC notation).
>
> Regards,
>
> Rainer
>
>>> -----Original Message-----
>>> From: fhanik@apache.org [mailto:fhanik@apache.org]
>>> Sent: Tuesday, September 01, 2009 1:22 PM
>>> To: dev@tomcat.apache.org
>>> Subject: svn commit: r810132 - /tomcat/tc6.0.x/trunk/STATUS.txt
>>>
>>> Author: fhanik
>>> Date: Tue Sep  1 17:21:59 2009
>>> New Revision: 810132
>>>
>>> URL: http://svn.apache.org/viewvc?rev=810132&view=rev
>>> Log:
>>> proposal
>>>
>>> Modified:
>>>     tomcat/tc6.0.x/trunk/STATUS.txt
>>>
>>> Modified: tomcat/tc6.0.x/trunk/STATUS.txt
>>> URL:
>>> http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/STATUS.txt?rev=810132
>>> &r1=810131&r2=810132&view=diff
>>> =======================================================================
>>> =======
>>> --- tomcat/tc6.0.x/trunk/STATUS.txt (original)
>>> +++ tomcat/tc6.0.x/trunk/STATUS.txt Tue Sep  1 17:21:59 2009
>>> @@ -321,3 +321,25 @@
>>>    +1: funkman
>>>    -1:
>>>
>>> +
>>> +* Fix VirtualWebappClassLoader file directives
>>> +  Index: java/org/apache/catalina/loader/VirtualWebappLoader.java
>>> +===================================================================
>>> +--- java/org/apache/catalina/loader/VirtualWebappLoader.java
>>>       (revision 810099)
>>> ++++ java/org/apache/catalina/loader/VirtualWebappLoader.java
>>>       (working copy)
>>> +@@ -92,9 +92,9 @@
>>> +                 continue;
>>> +             }
>>> +             if (file.isDirectory()) {
>>> +-                addRepository("file:/" + file.getAbsolutePath() +
>>> "/");
>>> ++                addRepository("file://" + file.getAbsolutePath() +
>>> "/");
>>> +             } else {
>>> +-                addRepository("file:/" + file.getAbsolutePath());
>>> ++                addRepository("file://" + file.getAbsolutePath());
>>> +             }
>>> +         }
>>> +
>>> +  +1: fhanik
>>> +  -1:
>>> +
>>> +
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: dev-help@tomcat.apache.org
>>>
>>
>>
>
> --
> kippdata
> informationstechnologie GmbH   Tel: 0228 98549 -0
> Bornheimer Str. 33a            Fax: 0228 98549 -50
> 53111 Bonn                     www.kippdata.de
>
> HRB 8018 Amtsgericht Bonn / USt.-IdNr. DE 196 457 417
> Geschäftsführer: Dr. Thomas Höfer, Rainer Jung, Sven Maurmann
> ===============================
> kippdata
> informationstechnologie GmbH   Tel: +49 228 98549 -0
> Bornheimer Str. 33a            Fax: +49 228 98549 -50
> D-53111 Bonn                   www.kippdata.de
>
> HRB 8018 Amtsgericht Bonn / USt.-IdNr. DE 196 457 417
> Geschäftsführer: Dr. Thomas Höfer, Rainer Jung, Sven Maurmann
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message