You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jesse Klaasse <Je...@indicia.nl> on 2008/06/24 09:14:29 UTC

URL encoding problem IIS6 / JK1.2.25 / Tomcat 5.5.20

I have recently migrated a production server from IIS5 / Resin 3.0.14 to
IIS6 / JK1.2.25 / Tomcat 5.5.20. Now, there seems to be a problem with
the URL translation from IIS to Tomcat.

I have this file in a webapp, called test[brackets].jsp.
When I try http://localhost:8080/webapp/test[brackets].jsp, everything
is working fine. So Tomcat understands the square brackets (appearing in
the Tomcat access log as test[brackets].jsp).

I have also a plain HTML file, called test[brackets].html.
When I try http://localhost/test[brackets].html, it's also working. IIS
by itself understands the square brackets, too.

Now, we try the whole link through the JK connector:
http://localhost/webapp/test[brackets].jsp
This doesn't work, and results in a 404 error (appearing in both IIS and
Tomcat's log as test%5Bbrackets%5D.jsp, Tomcat with a 404, IIS with a
200).

So, there seems to be SOMETHING wrong with the connector (or the
connector configuration) in combination with special characters. When I
try the same with a file called test.jsp, everything is working fine.

The Connector tag in server.xml doesn't have any of the encoding
attributes specified, so default encoding is used. Furthermore, the
uri_select key hasn't been set for the Isapi Redirector, so I guess
default mode ("proxy") is used.

Anyone? Thanks in advance! Kind regards, Jesse Klaasse.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: URL encoding problem IIS6 / JK1.2.25 / Tomcat 5.5.20

Posted by Jesse Klaasse <Je...@indicia.nl>.
André Warnier wrote:
>[...]
>Now, I should add that using [ and ] in URL's is not really something I would recommend, if only for legibility reasons.  It will always make people wonder if what they're seeing in the logfile is normal, or if it's some programming syntax which "escaped" there.
>And I would bet that naming your servlet that way is also going to bring you trouble if you ever have to reference it in a Javascript line for instance.

I completely agree with you when you're saying [ and ] are not recommended in URL's. However, I don't really have a say in that, something to do with politics and legacy stuff.. Thanks again for your help!

Jesse.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: URL encoding problem IIS6 / JK1.2.25 / Tomcat 5.5.20

Posted by André Warnier <aw...@ice-sa.com>.
Jesse Klaasse wrote:
[...]

Good.
Now, I should add that using [ and ] in URL's is not really something I 
would recommend, if only for legibility reasons.  It will always make 
people wonder if what they're seeing in the logfile is normal, or if 
it's some programming syntax which "escaped" there.
And I would bet that naming your servlet that way is also going to bring 
you trouble if you ever have to reference it in a Javascript line for 
instance.

André


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: URL encoding problem IIS6 / JK1.2.25 / Tomcat 5.5.20

Posted by André Warnier <aw...@ice-sa.com>.
Jesse Klaasse wrote:
[...]

Good.
Now, I should add that using [ and ] in URL's is not really something I 
would recommend, if only for legibility reasons.  It will always make 
people wonder if what they're seeing in the logfile is normal, or if 
it's some programming syntax which "escaped" there.
And I would bet that naming your servlet that way is also going to bring 
you trouble if you ever have to reference it in a Javascript line for 
instance.

André


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: URL encoding problem IIS6 / JK1.2.25 / Tomcat 5.5.20

Posted by Jesse Klaasse <Je...@indicia.nl>.
André Warnier wrote:

>It would appear (from the logs), that there is some double-encoding of the URI going on.
>[snip]
>But, if somewhere along the line, a piece of code was receiving the encoded URI "http://.../test%5Bbrackets%5D.jsp", and decided to re-encode it again using the "% hex hex" method, then you would get this URI : "http://.../test%255Bbrackets%255D.jsp" (where "%25" is the encoded version of "%").
>Then the next step would decode this URI back into "http://.../test%5Bbrackets%5D.jsp", and that is what the server would try to access, what would be logged, and also what you seem to experience.
>
>So, which is the culprit which re-encodes something it should not ?
>And is there not some parameter somewhere which forces it to do so ?

Thanks for your excellent answer. I have fixed the problem now. There is a setting for the isapi_redirecor called "uri_select". This parameter controls the URI's which are passed to Tomcat from IIS. It defaults to value "proxy", which leads to some re-encoding. I have changed the parameter's value to "unparsed" now, which has solved the problem.

For those who want to know more, the parameter is explained here: http://tomcat.apache.org/connectors-doc/reference/iis.html

Jesse.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: URL encoding problem IIS6 / JK1.2.25 / Tomcat 5.5.20

Posted by André Warnier <aw...@ice-sa.com>.

Jesse Klaasse wrote:
[snip]

> Now, we try the whole link through the JK connector:
> http://localhost/webapp/test[brackets].jsp
> This doesn't work, and results in a 404 error (appearing in both IIS and
> Tomcat's log as test%5Bbrackets%5D.jsp, Tomcat with a 404, IIS with a
> 200).
> 

Thanks for the excellent problem description.
It would appear (from the logs), that there is some double-encoding of 
the URI going on.

To simplify, I will assume that you are starting from a static html 
page, loaded in your browser from the local disk, and that this html 
page contains a link written as href="http://.../test[brackets].jsp".
(Please check this. I know it seems evident, but just to make sure that 
you are not starting from a URl that already has the [ ] pre-encoded..)

I will also assume that %5B and %5D are the correct "% hex hex" encoding 
for the characters "[" and "]" respectively.

What *should* happen is :
- when you click on the link, the browser should encode it into 
"http://.../test%5Bbrackets%5D.jsp" *before* sending it to the server.
That is because "[" and "]" are not within the acceptable ranges for 
unencoded URI characters, and it is normal.
- the server, when receiving this URL, should (immediately) decode it 
back into ".../test[brackets].jsp"; and that should also be what is 
processed, and logged.

But, if somewhere along the line, a piece of code was receiving the 
encoded URI "http://.../test%5Bbrackets%5D.jsp", and decided to 
re-encode it again using the "% hex hex" method, then you would get this 
URI : "http://.../test%255Bbrackets%255D.jsp" (where "%25" is the 
encoded version of "%").
Then the next step would decode this URI back into 
"http://.../test%5Bbrackets%5D.jsp", and that is what the server would 
try to access, what would be logged, and also what you seem to experience.

So, which is the culprit which re-encodes something it should not ?
And is there not some parameter somewhere which forces it to do so ?

André





---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org