I am using Javascript method decodeURIComponent
to decode an encoded URL. Now I am having an issue, that sometimes the URL is get encoded twice during redirection b
Repeatedly decoding until you find no %
signs will work over 99% of the time. It'll work even better if you repeatedly call so long as a match for /%[0-9a-f]{2}/i
can be found.
However, if I were (for some bizarre reason) to name a file 100%achieved
, that would cause a problem because %ac
would be decoded to ¬
, causing the decode to fail. Unfortunately there's no way to detect this case.
Ideally you should know if something is encoded more than once, and optimally you shouldn't let it happen in the first place.