0

I am having an issue with URL encoding. When I am executing URL on browser, server is encoding it again and again, however the url is already encoded to UTF-8.

eg. http://test.com:80/?gotoUrl=http%3A%2F%2Fclosewindow.xyz.com&modal=true

I am getting - https://test.com/?gotoUrl=http%253A%252F%252Fclosewindow.xyz.com&modal=true

I am running my application on HTTPS and redirecting any request on 80 to HTTPS secure port 443. This problem only occurs if I send request on port 80 and server is redirecting it to secure port 443. If I make request on secure port 443, this problem does not occur.

Following is my tomcat configuration,

<Connector port="8080" 
           protocol="HTTP/1.1" 
           connectionTimeout="5000" 
           compression="on"
           compressionMinSize="128"
           compressableMimeType="text/html,text/xml,text/plain,text/css,text/javascript,text    /json,
                                 application/x-javascript,application/javascript,application/json" 
           enableLookups="false"
           maxPostSize="4096"
           URIEncoding="UTF-8"
       redirectPort="8443"

/>
<Connector  port="8009" 
            protocol="AJP/1.3" 
            URIEncoding="UTF-8"
/>

<Connector
   protocol="HTTP/1.1"
   port="8443" maxThreads="200"
   scheme="https" secure="true" SSLEnabled="true"
   keystoreFile="/path/keystore" keystorePass="password"
   clientAuth="false" sslProtocol="TLS"/>

My environment is like Apache2.2 in on the front and tomcat7.x is connected via AJP with Apache server.

I dig into this issue and I found out that the issue is down to AJP that is using iso-8859-1, however tomcat & Apache are working fine and using UTF-8 encoding. Is there anyway to set encoding to UTF-8 in AJP? I am using mod_proxy_ajp.

Thanks in advance. I would appreciate any help on this.

Arsalan
  • 15
  • 1
  • 7
  • It would be good to know, which tomcat version you are using. – Reboot Sep 25 '13 at 12:31
  • @Reboot I am using 7.0.26 version of tomcat. This is happening on uat environment, however i can't reproduce it locally. The only difference is uat environment resides behind akamai servers. – Arsalan Sep 25 '13 at 13:27
  • If you have additional information your should try to improve the question by adding it. The information that it only happens with Akamai servers could help others to find a solution. – Reboot Sep 25 '13 at 17:29
  • Thanks @Reboot and EJP, I found out the issue is with AJP, I have modified my question. I would really appreciate any help on this. – Arsalan Sep 26 '13 at 09:29

1 Answers1

0

I suggest the browser is doing it. It doesn't make sense for Tomcat to be doing it. Tomcat would be decoding, not encoding. Try it in the browser with no encoding at all.

user207421
  • 305,947
  • 44
  • 307
  • 483
  • When tomcat sends a redirect it has to encode the URL in the HTTP header, if it has been decoded before generating the redirect. – Reboot Sep 25 '13 at 12:26
  • @Reboot Exactly, and the result of decoding plus encoding isn't a double encoding, is it? – user207421 Sep 25 '13 at 12:28
  • You wrote Tomcat would not be doing any encoding, which is not correct, if it decodes the URL and sends a redirect. If the encoding does not work correctly and encodes the wrong input this could be an issue of Tomcat. – Reboot Sep 25 '13 at 12:39
  • @Reboot No, it would be an issue with the original wrong encoding. – user207421 Sep 25 '13 at 23:22