Tag: urlencode

为什么要使用urlencode?

我正在写一个Web应用程序,并学习如何urlencode的HTML链接… 所有的urlencode问题在这里(见下面的标签)是“如何…? 的问题。 我的问题不是“如何?” 但为什么?”。 即使是维基百科的文章也只涉及它的机制: http://en.wikipedia.org/wiki/Urlencode,但不是为什么我应该在我的应用程序中使用urlencode。 使用(或不使用)urlencode的安全含义是什么? 如何使用urlencode失败被利用 ? 什么样的错误或失败可以出现与未编码的url? 我问,因为即使没有urlencode,一个链接到我的应用程序开发网站,如下面的预期工作: http://myapp/my%20test/ée/ràé 为什么要使用urlencode? 或者另一种说法: 什么时候应该使用urlencode? 在什么样的情况下?

如何在Groovy中编码URL?

Groovy中是否有一种URLEncode? 我无法find任何string→stringURL编码工具。 例如: dehydrogenase (NADP+) → dehydrogenase%20(NADP%2b) (而不是%20也是可以接受的,因为有些实现这样做)

如何在URL中对加号(+)进行编码

下面的URL链接将打开一个新的Google邮件窗口。 我遇到的问题是Google会用空格replace电子邮件正文中的所有加号(+)。 它看起来只发生在+号上。 任何build议如何补救? (我正在使用ASP.NET网页) https://mail.google.com/mail?view=cm&tf=0&to=someemail@somedomain.com&su=some主题&身体=嗨,那里+你好 (在正文邮件中,“Hi there + Hello there”将显示为“Hi there there there”)

http_build_query()没有url编码

有没有一种方法可以使用http_build_query()而无需根据某些RFC标准进行URL编码? 为什么我不想要URL编码的一切:我查询Ebay API ..他们诚实地坚持参数名称不是URL编码,就像括号中的逗号。 例如DomainName(0)是一个参数,如果这些parens被编码,则查询失败。

urllib.urlencode不喜欢unicode值:这个解决方法怎么样?

如果我有一个像这样的对象: d = {'a':1, 'en': 'hello'} 然后我可以把它传递给urllib.urlencode ,没问题: percent_escaped = urlencode(d) print percent_escaped 但是,如果我尝试传递一个types为unicode的值的对象,游戏结束: d2 = {'a':1, 'en': 'hello', 'pt': u'olá'} percent_escaped = urlencode(d2) print percent_escaped # This fails with a UnicodeEncodingError 所以我的问题是关于准备传递给urlencode的对象的可靠方法。 我想出了这个函数,我简单地遍历对象,并编码string或unicodetypes的值: def encode_object(object): for k,v in object.items(): if type(v) in (str, unicode): object[k] = v.encode('utf-8') return object 这似乎工作: d2 = {'a':1, 'en': […]

为什么curl截断这个查询string?

我相信这个问题的答案将会是一些非常明显的字符编码问题。 我在命令行上使用curl来testingpython应用程序中的一些端点。 端点需要经纬度的url参数。 没什么特别的 我input命令: curl -v -L http://localhost:5000/pulse/?lat=41.225&lon=-73.1 服务器响应,具有详细的curl输出: * Connected to localhost (127.0.0.1) port 5000 (#0) > GET /pulse/?lat=41.225 HTTP/1.1 > User-Agent: curl/7.21.6 (i686-pc-linux-gnu) libcurl/7.21.6 OpenSSL/1.0.0e zlib/1.2.3.4 libidn/1.22 librtmp/2.3 > Host: localhost:5000 > Accept: */* > * HTTP 1.0, assume close after body < HTTP/1.0 500 INTERNAL SERVER ERROR < Content-Type: application/json < […]

Facebook错误“validationvalidation码错误”

很奇怪的错误。 我使用gide http://developers.facebook.com/docs/authentication/ 。 所以我创buildfb请求并传递redirect_uri。 我在本地使用testing网站。 所以如果我通过 redirect_uri = http://localhost/test_blog/index.php 它工作正常,但如果我通过 redirect_uri = http://localhost/test_blog/index.php?r = site / oauth2 它不想工作。 我尝试使用 redirect_uri =。 urlencode(' http://localhost/test_blog/index.php?r = site / oauth2 ) 但没有工作。 我试图解释。 我成功获取代码,但是当我访问https://graph.facebook.com/me?access_token我得到错误“错误validationvalidation码”。 我查了天哪,错误是在?r =站点/ oauth2,但我需要传递一些参数有人可以帮我吗? 我阅读后http://forum.developers.facebook.net/viewtopic.php?id=70855但没有为我工作

如何在PHP中正确的URL编码一个string?

我在做一个search页面,在那里你键入一个search查询和表单提交到search.php?query=your query 。 什么PHPfunction是最好的,我应该使用编码/解码search查询?

PHP:将string中的空格转换为%20?

如何将string中的空格转换为%20 ? 这是我的尝试: $str = "What happens here?"; echo urlencode($str); 输出是"What+happens+here%3F" ,所以空格不表示为%20 。 我究竟做错了什么?

Ruby url编码string

我如何URI ::编码一个string,如: \x12\x34\x56\x78\x9a\xbc\xde\xf1\x23\x45\x67\x89\xab\xcd\xef\x12\x34\x56\x78\x9a 为了得到它的格式如下: %124Vx%9A%BC%DE%F1%23Eg%89%AB%CD%EF%124Vx%9A (根据RFC 1738) 以下是我所尝试的: irb(main):123:0> URI::encode "\x12\x34\x56\x78\x9a\xbc\xde\xf1\x23\x45\x67\x89\xab\xcd\xef\x12\x34\x56\x78\x9a" ArgumentError: invalid byte sequence in UTF-8 from /usr/local/lib/ruby/1.9.1/uri/common.rb:219:in `gsub' from /usr/local/lib/ruby/1.9.1/uri/common.rb:219:in `escape' from /usr/local/lib/ruby/1.9.1/uri/common.rb:505:in `escape' from (irb):123 from /usr/local/bin/irb:12:in `<main>' 也, irb(main):126:0> CGI::escape "\x12\x34\x56\x78\x9a\xbc\xde\xf1\x23\x45\x67\x89\xab\xcd\xef\x12\x34\x56\x78\x9a" ArgumentError: invalid byte sequence in UTF-8 from /usr/local/lib/ruby/1.9.1/cgi/util.rb:7:in `gsub' from /usr/local/lib/ruby/1.9.1/cgi/util.rb:7:in `escape' from (irb):126 from /usr/local/bin/irb:12:in `<main>' 我已经看了所有关于互联网,并没有发现(或更可能错过)一个方法来做到这一点,虽然我几乎积极的,有一天,我没有任何麻烦,所有这一切。 谢谢!