url-encoding

Test if string is URL encoded in PHP

拜拜、爱过 提交于 2019-11-29 11:06:18
问题 How can I test if a string is URL encoded? Which of the following approaches is better? Search the string for characters which would be encoded, which aren't, and if any exist then its not encoded, or Use something like this which I've made: function is_urlEncoded($string){ $test_string = $string; while(urldecode($test_string) != $test_string){ $test_string = urldecode($test_string); } return (urlencode($test_string) == $string)?True:False; } $t = "Hello World > how are you?"; if(is

asp .net query string encoding and decoding

。_饼干妹妹 提交于 2019-11-29 10:56:27
I type the following url into my web browser and press enter. http://localhost/website.aspx?paymentID=6++7d6CZRKY%3D&language=English Now in my code when I do HttpContext.Current.Request.QueryString["paymentID"], I get 6 7d6CZRKY= but when I do HttpContext.Current.Request.QueryString.ToString() I see the following: paymentID=6++7d6CZRKY%3D&language=English The thing I want to extract the actual payment id that the user typed in the web browser URL. I am not worried as to whether the url is encoded or not. Because I know there is a weird thing going on here %3D and + sign at the same time ! But

How to URL encode periods?

為{幸葍}努か 提交于 2019-11-29 02:58:23
I need to URL encode some periods since I have to pass some document path along and it is like this http://example.com/test.aspx?document=test.docx So test.docx is causing me an error of an illegal character. So I need to change it to . --> %2E I tried to use Server.UrlEncode string b = Server.UrlEncode("http://example.com/test.aspx?document=test.docx"); but I get "http%3a%2f%2fexample.com%2ftest.aspx%3fdocument%3dtest.docx" So do I have to use like a string replace and do it manually and replace all periods with that code? The period there isn't he problem (given that %2E doesn't solve the

mod_rewrite NE flag - When is it helpful to encode special chars in the URL?

时间秒杀一切 提交于 2019-11-29 02:45:43
问题 I've been looking at the [NE] (noescape) flag in mod_rewrite. After some thought I couldn't figure out a situation when I would NOT want to use the flag. Meaning, it seems most helpful to keep the flag enabled in almost every RewriteRule . Not invoking this flag has caused me problems in a few circumstances. Most of the rules that I deal with are HTTP redirects ( [R] ), rather than passing through. Would someone shed some light as to when it is helpful to have mod_rewrite encode the URL? Is

python url unquote followed by unicode decode

雨燕双飞 提交于 2019-11-29 01:23:18
问题 I have a unicode string like '%C3%A7%C3%B6asd+fjkls%25asd' and I want to decode this string. I used urllib.unquote_plus(str) but it works wrong. expected : çöasd+fjkls%asd result : çöasd fjkls%asd double coded utf-8 characters( %C3%A7 and %C3%B6 ) are decoded wrong. My python version is 2.7 under a linux distro. What is the best way to get expected result? 回答1: You have 3 or 4 or 5 problems ... but repr() and unicodedata.name() are your friends; they unambiguously show you exactly what you

When should an asterisk be encoded in an HTTP URL?

岁酱吖の 提交于 2019-11-28 22:50:46
According to RFC1738 , an asterisk (*) "may be used unencoded within a URL": Thus, only alphanumerics, the special characters "$-_.+!*'(),", and reserved characters used for their reserved purposes may be used unencoded within a URL. However, w3.org's Naming and Addressing material says that the asterisk is "reserved for use as having special signifiance within specific schemes" and implies that it should be encoded. Also, according to RFC3986 , a URL is a URI: The term "Uniform Resource Locator" (URL) refers to the subset of URIs that, in addition to identifying a resource, provide a means of

How do you unescape URLs in Java?

无人久伴 提交于 2019-11-28 11:52:35
When I read the xml through a URL's InputStream, and then cut out everything except the url, I get " http://cliveg.bu.edu/people/sganguly/player/%20Rang%20De%20Basanti%20-%20Tu%20Bin%20Bataye.mp3 ". As you can see, there are a lot of "%20"s. I want the url to be unescaped. Is there any way to do this in Java, without using a third-party library? This is not unescaped XML, this is URL encoded text. Looks to me like you want to use the following on the URL strings. URLDecoder.decode(url); This will give you the correct text. The result of decoding the like you provided is this. http://cliveg.bu

C#: base64url according to RFC4648

[亡魂溺海] 提交于 2019-11-28 11:24:13
I'm looking for a (fast) standard implementation for base64url according to RFC4648 in C#. I found HttpServerUtility.UrlTokenEncode but it looks like this doesn't follow RFC4648 (UrlTokenEncode adds a number at the end which indicates the number of = signs that were removed; see here and here ). Example: base64 encoding: Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes("AA")); //returns "QUE=" base64url encoding: HttpServerUtility.UrlTokenEncode(System.Text.Encoding.ASCII.GetBytes("AA")); //returns "QUE1" but I would expect "QUE" Based on the comments, it sounds like

Using Perl, how do I decode or create those %-encodings on the web?

筅森魡賤 提交于 2019-11-28 11:03:16
I need to handle URI (i.e. percent) encoding and decoding in my Perl script. How do I do that? This is a question from the official perlfaq . We're importing the perlfaq to Stack Overflow . This is the official FAQ answer minus subsequent edits. Those % encodings handle reserved characters in URIs, as described in RFC 2396, Section 2 . This encoding replaces the reserved character with the hexadecimal representation of the character's number from the US-ASCII table. For instance, a colon, : , becomes %3A . In CGI scripts, you don't have to worry about decoding URIs if you are using CGI.pm .

Do ampersands still need to be encoded in URLs in HTML5?

≡放荡痞女 提交于 2019-11-28 10:42:44
I learned recently (from these questions ) that at some point it was advisable to encode ampersands in href parameters. That is to say, instead of writing: <a href="somepage.html?x=1&y=2">...</a> One should write: <a href="somepage.html?x=1&y=2">...</a> Apparently, the former example shouldn't work, but browser error recovery means it does. Is this still the case in HTML5? We're now past the era of draconian XHTML requirements. Was this a requirement of XHTML's strict handling, or is it really still something that I should be aware of as a web developer? Ray Toal It is true that one of the