Percent-Encoded Percent in URI
Posted
by Lukas
on Stack Overflow
See other posts from Stack Overflow
or by Lukas
Published on 2010-03-22T16:27:50Z
Indexed on
2010/03/22
16:31 UTC
Read the original article
Hit count: 481
In our application, it is possible for a user to upload files then download them later. We don't restrict them from having any special characters in the file name.
The problem comes in when we create the link for the user to download the file. I use the Java URL encoder to encode the file name that gets put into the href of the link, but I'm still having problems with percent (%) signs.
For example, if the user uploads a file named fi%le.jpg, the href that gets generated is fi%25le.jpg, and everything is fine. The problem is when the percent sign is right before the period (i.e., file%.jpg, which gets converted to file%25.jpg). When the user clicks on the link, they get a 404 (Not Found) error.
The strange thing is that it is not a problem if the two characters following the percent sign are hex characters.... Weird, eh?
Any help is appreciated. I am using Tomcat/Struts. Could the built-in URL decoder have anything to do with this problem?
© Stack Overflow or respective owner