urlencoded Forward slash is breaking URL

Apache denies all URLs with %2F in the path part, for security reasons: scripts can’t normally (ie. without rewriting) tell the difference between %2F and / due to the PATH_INFO environment variable being automatically URL-decoded (which is stupid, but a long-standing part of the CGI specification so there’s nothing can be done about it). You … Read more

GETting a URL with an url-encoded slash

This is a terrible hack, bound to be incompatible with future versions of the framework and so on. But it works! (on my machine…) Uri uri = new Uri(“http://example.com/%2F”); ForceCanonicalPathAndQuery(uri); using (WebClient webClient = new WebClient()) { webClient.DownloadData(uri); } void ForceCanonicalPathAndQuery(Uri uri){ string paq = uri.PathAndQuery; // need to access PathAndQuery FieldInfo flagsFieldInfo = typeof(Uri).GetField(“m_Flags”, … Read more

urlencode vs rawurlencode?

It will depend on your purpose. If interoperability with other systems is important then it seems rawurlencode is the way to go. The one exception is legacy systems which expect the query string to follow form-encoding style of spaces encoded as + instead of %20 (in which case you need urlencode). rawurlencode follows RFC 1738 … Read more

How to do URL decoding in Java?

This does not have anything to do with character encodings such as UTF-8 or ASCII. The string you have there is URL encoded. This kind of encoding is something entirely different than character encoding. Try something like this: try { String result = java.net.URLDecoder.decode(url, StandardCharsets.UTF_8.name()); } catch (UnsupportedEncodingException e) { // not going to happen … Read more