You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Christopher Kohlhaas <ch...@einfachanders.de> on 2003/06/07 12:37:42 UTC

Problem with encoded URIs in FileSource

Hello,

I've encountered a Problem in SourceResolve with 
files like:

  "/tmp/dir with space/fortress.xconf" (contains Spaces)

or

  "c:\Übersicht\fortress.xconf" (contains german Umlaute)

The first one correctly gets encoded to the URI

  "file:/tmp/dir%20with%20spaces/fortress.xconf"

The later one gets encoded to 

  "file:/c:\%c3%9cbersicht\fortress.xconf"

The encoding could happen for example in the getSystemResource method
of the classLoader.

  configURL = ClassLoader.getSystemResource("fortress.xconf");

The Problem is: The uri will never be decoded in FileSource:

  public FileSource(String uri) throws SourceException,..
  {
      int pos = SourceUtil.indexOfSchemeColon(uri);
      if (pos == -1)
      {
          throw new MalformedURLException("Invalid URI : " + uri);
      }

      String scheme = uri.substring(0, pos);
      // The URI will not be decoded 
      String fileName = uri.substring(pos + 1);
      init(scheme, new File(fileName));
  }

However under under java 1.3.1 all works fine only java 1.4.1
fails. Tried to place a decode method, but that only fixed the space
problem.

Unfortunatly I've no time to investigate further, so I worked around
this by not using SourceResolverImpl at all.


Regards Christopher




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


Re: Problem with encoded URIs in FileSource

Posted by Bruno Dumon <br...@outerthought.org>.
On Sat, 2003-06-07 at 12:37, Christopher Kohlhaas wrote:
> Hello,
> 
> I've encountered a Problem in SourceResolve with 
> files like:
> 
>   "/tmp/dir with space/fortress.xconf" (contains Spaces)
> 
> or
> 
>   "c:\Übersicht\fortress.xconf" (contains german Umlaute)
> 
> The first one correctly gets encoded to the URI
> 
>   "file:/tmp/dir%20with%20spaces/fortress.xconf"
> 
> The later one gets encoded to 
> 
>   "file:/c:\%c3%9cbersicht\fortress.xconf"
> 
> The encoding could happen for example in the getSystemResource method
> of the classLoader.
> 
>   configURL = ClassLoader.getSystemResource("fortress.xconf");
> 
> The Problem is: The uri will never be decoded in FileSource:
> 
>   public FileSource(String uri) throws SourceException,..
>   {
>       int pos = SourceUtil.indexOfSchemeColon(uri);
>       if (pos == -1)
>       {
>           throw new MalformedURLException("Invalid URI : " + uri);
>       }
> 
>       String scheme = uri.substring(0, pos);
>       // The URI will not be decoded 
>       String fileName = uri.substring(pos + 1);
>       init(scheme, new File(fileName));
>   }
> 
> However under under java 1.3.1 all works fine only java 1.4.1
> fails. Tried to place a decode method, but that only fixed the space
> problem.
> 
> Unfortunatly I've no time to investigate further, so I worked around
> this by not using SourceResolverImpl at all.
> 

Hi Christopher,

I stumbled across the same problem some time ago (in a different
context). I have now comitted changes to do path-decoding in FileSource.
It works fine with your "Übersicht" example, could you give it a try?

Regards,

Bruno

-- 
Bruno Dumon                             http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno@outerthought.org                          bruno@apache.org


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