apachetomcat7urlencodeapache-shindig

Apache Tomcat with Mod_JK URL decoding issue


I am using apache tomcat with mod_jk and running shindig on it. i am trying to pass the below url to it

http://download.finance.yahoo.com/d/quotes.csv?s=^GSPTSE+^SPCDNX+MIC.TO+ABX.TO+AEM.TO&f=snl1d1t1c1&e=.csv&random=5683

and it fails giving error 400 (Invalid url parameter)

if i pass the url without any parameter it works perfectly fine.

you can have look at consol log for below url

http://portaltab.com/shindig/gadgets/ifr?url=http://igstock.googlecode.com/svn/trunk/modules/canada_stock_market_on_ig.xml

i tried so many things, but no luck. i am not sure whether it is tomcat issue or something else.

if any expert experience the same issue could you please share some info.

Thank you.

Regards, Raj


Solution

  • Most likely your issue is because carets (^) are not valid URL characters. They are considered "unsafe" per RFC1738. Quoting from that RFC:

    ...Other characters are unsafe because gateways and other transport agents are known to sometimes modify such characters. These characters are "{", "}", "|", "\", "^", "~", "[", "]", and "`".

    You should encode the carets in your URL using %5E. Some programmers and libraries do not do this by default as it is not a commonly used symbol and some systems handle it without error even if not fully compliant.

    It's not clear from your example if you are encoding your URL, and if so, where you are doing so. If not encoding at all, you might also need to encode the plus symbols. A fully encoded s value per your example would be:

    %5EGSPTSE%2B%5ESPCDNX%2BMIC.TO%2BABX.TO%2BAEM.TO