You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lenya.apache.org by Sterzl Christian <ch...@pdts.at> on 2006/01/16 11:41:15 UTC

bug in org.apache.lenya.net.ProxyManager

There has been a bug in ProxyManager I spotted in
org.apache.lenya.net.ProxyManager#readConfig.
 
If spaces are in the path an URISyntaxException is thrown. Thus I think
it does make sense to add an replaceAll(" ", "%20") to the URI string.
 
configFile = new File(new
java.net.URI(ProxyManager.class.getClassLoader().getResource(fname).toSt
ring().replaceAll(" ","%20")));

What do you think. Do you think also other classes do have this bug?

Regards, Christian

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


Re: bug in org.apache.lenya.net.ProxyManager

Posted by Christian Sterzl <ch...@pdts.at>.
> >>>>>org.apache.lenya.net.ProxyManager#readConfig.
> >>>>>configFile = new File(new
> >>>>>java.net.URI(ProxyManager.class.getClassLoader().getResource(fname).toSt
> >>>>>ring().replaceAll(" ","%20")));

> >>The problem is that the URLEncoder adds the protocol and server information.
 
> > I think it is better to use the most simple method and just work with the
> > replaceAll-method. 

> This only applies if the solution solves the problem without creating
> other problems. If the code appears to do URL encoding, but actually doesn't,
> this is clearly a bug.

I will let it run with my above described solution and will monitor the
behaviour. If problems occur I will report it and think about an appropriate
solution.

Christian



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


Re: bug in org.apache.lenya.net.ProxyManager

Posted by Andreas Hartmann <an...@apache.org>.
Christian Sterzl wrote:
> Andreas Hartmann <andreas <at> apache.org> writes:
> 
> 
>>>>>There has been a bug in ProxyManager I spotted in
>>>>>org.apache.lenya.net.ProxyManager#readConfig.
>>>>>
>>>>>If spaces are in the path an URISyntaxException is thrown. Thus I think
>>>>>it does make sense to add an replaceAll(" ", "%20") to the URI string.
>>>>>
>>>>>configFile = new File(new
>>>>>java.net.URI(ProxyManager.class.getClassLoader().getResource(fname).toSt
>>>>>ring().replaceAll(" ","%20")));
>>>>>
>>
>>The problem is that the URLEncoder adds the protocol and server information.
>>You could try to add this yourself and remove it after the encoding. Maybe
>>you could use the debugger to see what exactly is happening.
>>
> 
> 
> I think it is better to use the most simple method and just work with the
> replaceAll-method. 
> 
> Ya know, KISS

This only applies if the solution solves the problem without creating
other problems. If the code appears to do URL encoding, but actually doesn't,
this is clearly a bug.

-- Andreas


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


Re: bug in org.apache.lenya.net.ProxyManager

Posted by Christian Sterzl <ch...@pdts.at>.
Andreas Hartmann <andreas <at> apache.org> writes:

> >>>There has been a bug in ProxyManager I spotted in
> >>>org.apache.lenya.net.ProxyManager#readConfig.
> >>> 
> >>>If spaces are in the path an URISyntaxException is thrown. Thus I think
> >>>it does make sense to add an replaceAll(" ", "%20") to the URI string.
> >>> 
> >>>configFile = new File(new
> >>>java.net.URI(ProxyManager.class.getClassLoader().getResource(fname).toSt
> >>>ring().replaceAll(" ","%20")));
> >>>
> The problem is that the URLEncoder adds the protocol and server information.
> You could try to add this yourself and remove it after the encoding. Maybe
> you could use the debugger to see what exactly is happening.
> 

I think it is better to use the most simple method and just work with the
replaceAll-method. 

Ya know, KISS

--- Christian






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


Re: bug in org.apache.lenya.net.ProxyManager

Posted by Andreas Hartmann <an...@apache.org>.
Christian Sterzl wrote:
> Andreas Hartmann <andreas <at> apache.org> writes:
> 
> 
>>Sterzl Christian wrote:
>>
>>>There has been a bug in ProxyManager I spotted in
>>>org.apache.lenya.net.ProxyManager#readConfig.
>>> 
>>>If spaces are in the path an URISyntaxException is thrown. Thus I think
>>>it does make sense to add an replaceAll(" ", "%20") to the URI string.
>>> 
>>>configFile = new File(new
>>>java.net.URI(ProxyManager.class.getClassLoader().getResource(fname).toSt
>>>ring().replaceAll(" ","%20")));
>>>
>>>What do you think. Do you think also other classes do have this bug?
>>
>>I'm not familiar with the code, but maybe what you're suggesting
>>could be achieved using URL encoding:
>>
>>java.net.URLEncoder.encode(...);
>>
> 
> If I do following:
> configFile = new File(new
> java.net.URI(java.net.URLEncoder.encode(ProxyManager.class.getClassLoader().
> getResource(fname).toString(),"US-ASCII")));
> I get an IllegalArgumentException: Path is not absolute.
> 
> Thus I don't know exactly how to work with the encoder.
> 
> Does anyone know a better way then I described it?

The problem is that the URLEncoder adds the protocol and server information.
You could try to add this yourself and remove it after the encoding. Maybe
you could use the debugger to see what exactly is happening.

-- Andreas


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


Re: bug in org.apache.lenya.net.ProxyManager

Posted by Christian Sterzl <ch...@pdts.at>.
Andreas Hartmann <andreas <at> apache.org> writes:

> 
> Sterzl Christian wrote:
> > There has been a bug in ProxyManager I spotted in
> > org.apache.lenya.net.ProxyManager#readConfig.
> >  
> > If spaces are in the path an URISyntaxException is thrown. Thus I think
> > it does make sense to add an replaceAll(" ", "%20") to the URI string.
> >  
> > configFile = new File(new
> > java.net.URI(ProxyManager.class.getClassLoader().getResource(fname).toSt
> > ring().replaceAll(" ","%20")));
> > 
> > What do you think. Do you think also other classes do have this bug?
> 
> I'm not familiar with the code, but maybe what you're suggesting
> could be achieved using URL encoding:
> 
> java.net.URLEncoder.encode(...);
> 
If I do following:
configFile = new File(new
java.net.URI(java.net.URLEncoder.encode(ProxyManager.class.getClassLoader().
getResource(fname).toString(),"US-ASCII")));
I get an IllegalArgumentException: Path is not absolute.

Thus I don't know exactly how to work with the encoder.

Does anyone know a better way then I described it?




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


Re: bug in org.apache.lenya.net.ProxyManager

Posted by Andreas Hartmann <an...@apache.org>.
Sterzl Christian wrote:
> There has been a bug in ProxyManager I spotted in
> org.apache.lenya.net.ProxyManager#readConfig.
>  
> If spaces are in the path an URISyntaxException is thrown. Thus I think
> it does make sense to add an replaceAll(" ", "%20") to the URI string.
>  
> configFile = new File(new
> java.net.URI(ProxyManager.class.getClassLoader().getResource(fname).toSt
> ring().replaceAll(" ","%20")));
> 
> What do you think. Do you think also other classes do have this bug?

I'm not familiar with the code, but maybe what you're suggesting
could be achieved using URL encoding:

java.net.URLEncoder.encode(...);


-- Andreas


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


Re: bug in org.apache.lenya.net.ProxyManager

Posted by Josias Thoeny <jo...@wyona.com>.
On Mon, 2006-01-16 at 11:41 +0100, Sterzl Christian wrote:
> There has been a bug in ProxyManager I spotted in
> org.apache.lenya.net.ProxyManager#readConfig.
>  
> If spaces are in the path an URISyntaxException is thrown. Thus I think
> it does make sense to add an replaceAll(" ", "%20") to the URI string.
>  
> configFile = new File(new
> java.net.URI(ProxyManager.class.getClassLoader().getResource(fname).toSt
> ring().replaceAll(" ","%20")));
> 
> What do you think. Do you think also other classes do have this bug?

ProxyManager.class.getClassLoader().getResource(fname) returns an URL
object, which _should_ be correctly url-encoded.
If it contains spaces, this is a bug in the classloader (or even lower)
and probably has something to do with 
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4273532

It is recommended to not install java applications in directories
containing spaces in the path.

Josias

> 
> Regards, Christian
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
> For additional commands, e-mail: dev-help@lenya.apache.org
> 
> 


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