urlencode

rawurlencode() urlencode() 函数 分析

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-01 18:21:04
rawurlencode string rawurlencode ( string $str ) 返回字符串,此字符串中除了 -_. 之外的所有非字母数字字符都将被替换成百分号( % )后跟两位十六进制数。这是在 RFC 1738 中描述的编码,是为了保护原义字符以免其被解释为特殊的 URL 定界符,同时保护 URL 格式以免其被传输媒体(像一些邮件系统)使用字符转换时弄乱。例如,如果你想在 FTP 的 URL 中包含密码: Example #1 rawurlencode() 示例 1 <?php echo '<a href="ftp://user:' , rawurlencode ( 'foo @+%/' ), '@ftp.example.com/x.txt">' ; ?> 或者,如果你想通过 URL 的 PATH_INFO 构成部分去传递信息: Example #2 rawurlencode() 示例 2 <?php echo '<a href="http://example.com/department_list_script/' , rawurlencode ( 'sales and marketing/Miami' ), '">' ; ?> urldecode string urldecode ( string $str ) 解码给出的已编码字符串中的任何 % ##

Why Does url-encoding the first slash after the domain break the url?

我是研究僧i 提交于 2019-12-01 17:14:10
问题 Salvete! I have discovered that a certain way of url encoding breaks the link. For the record %2f represents the forward slash character: / Now, consider this: Original Link: http://dottech.org/95285/this-is-the-pacific-barreleye-a-fish-with-a-transparent-head-amazing-photo-of-the-day javascript ( encodeURIComponent ) urlencoded link: http://dottech.org%2f95285%2fthis-is-the-pacific-barreleye-a-fish-with-a-transparent-head-amazing-photo-of-the-day Now, if you paste the encoded link into your

C - URL encoding

孤者浪人 提交于 2019-12-01 16:56:15
Is there a simple way to do URL encode in C? I'm using libcurl but I haven't found a method. Specifically, I need to do percent escapes. Oliver Charlesworth curl_escape which apparently has been superseded by curl_easy_escape In C based on wikipedia, without having to alloc and free. Make sure output buffer is at least 3X input URL string. Usually you only need to encode up to maybe 4K as URLs tend to be short so just do it on the stack. char rfc3986[256] = {0}; char html5[256] = {0}; void url_encoder_rfc_tables_init(){ int i; for (i = 0; i < 256; i++){ rfc3986[i] = isalnum( i) || i == '~' ||

Angular ui-router with url query parameter containing a “dot”

我的梦境 提交于 2019-12-01 16:54:49
In our Angular app we have to deal with id's that contain a "dot". For example: book = { id: '123.456' } We have problems using such id's as url parameters. All works well if navigation occurs through "Angular", namely clicking on the link that invokes $state.go('bookDetails', {bookId: book.id}); . But things do not work when reloading the page "Cannot GET /bookDetails?bookId=123.456" in the controller: $scope.viewBookDetails = function() { $state.go('bookDetails', {bookId: book.id}); } in the view <a href="" ng-click="viewBookDetails(); $event.stopPropagation();"> in the router: .state(

UrlEncode - Javascript vs. C# [duplicate]

十年热恋 提交于 2019-12-01 16:25:29
问题 This question already has answers here : Does C# have an equivalent to JavaScript's encodeURIComponent()? (7 answers) Closed 4 years ago . I have a URL which requires some parameters. The values of those parameters can be accented characters, so I absolutely need to UrlEncode them. Strangely, I see a difference between the behavior or Javascript and .NET. Let's pretend I try to UrlEncode the word "éléphant". In JavaScript (according to this WebSite: http://www.albionresearch.com/misc

Angular ui-router with url query parameter containing a “dot”

一曲冷凌霜 提交于 2019-12-01 16:00:56
问题 In our Angular app we have to deal with id's that contain a "dot". For example: book = { id: '123.456' } We have problems using such id's as url parameters. All works well if navigation occurs through "Angular", namely clicking on the link that invokes $state.go('bookDetails', {bookId: book.id}); . But things do not work when reloading the page "Cannot GET /bookDetails?bookId=123.456" in the controller: $scope.viewBookDetails = function() { $state.go('bookDetails', {bookId: book.id}); } in

URLDecoding requests

随声附和 提交于 2019-12-01 14:15:52
I am trying to get the original url from requests . Here is what I have so far: res = requests.get(...) url = urllib.unquote(res.url).decode('utf8') I then get an error that says: UnicodeEncodeError: 'ascii' codec can't encode characters in position 60-61: ordinal not in range(128) The original url I requested is: https://www.microsoft.com/de-at/store/movies/american-pie-pr\xc3\xa4sentiert-nackte-tatsachen/8d6kgwzl63ql And here is what happens when I try printing: >>> print '111', res.url 111 https://www.microsoft.com/de-at/store/movies/american-pie-pr%C3%A4sentiert-nackte-tatsachen

URLDecoding requests

ⅰ亾dé卋堺 提交于 2019-12-01 12:45:14
问题 I am trying to get the original url from requests . Here is what I have so far: res = requests.get(...) url = urllib.unquote(res.url).decode('utf8') I then get an error that says: UnicodeEncodeError: 'ascii' codec can't encode characters in position 60-61: ordinal not in range(128) The original url I requested is: https://www.microsoft.com/de-at/store/movies/american-pie-pr\xc3\xa4sentiert-nackte-tatsachen/8d6kgwzl63ql And here is what happens when I try printing: >>> print '111', res.url 111

Avoid URL-encoding in XSLT with output method html

╄→尐↘猪︶ㄣ 提交于 2019-12-01 12:24:56
I have a transformation that outputs HTML. In order to avoid self-closing tags that could break in older browsers (e.g. <img /> instead of <img></img> ) output-method has to be html . Then though URL-encoding is applied so that it breaks my application. See for example: Input <html> <head> </head> <body> {{example}} <a href="{{example}}" >abc</a> <img src="http://placehold.it/20x20"></img> </body> </html> Transformation <?xml version="1.0" encoding="utf-8"?> <xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes" /><!-- either -->

URL Encode all non alpha numeric in C#

最后都变了- 提交于 2019-12-01 04:09:24
I need to fully URL Encode an email address. HttpUtility.UrlEncode seems to ignore certain characters such as ! and . I need to pass an email address in a url formated like this: /Users/me@example.com/Comments Because my WebMethod uri template looks like this: [WebGet(UriTemplate = "Users/{emailAddress}/Comments")] The period breaks WCF and will not pass the email address to my REST webservice method. Removing the period passes the value just fine. I'm hoping there is a method which will encode all non alpha numeric characters since everything consuming this service will need to do this. EDIT