欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

url decode problem 解決方法

 更新時(shí)間:2011年12月26日 21:45:03   作者:  
今天被告訴了一個(gè)奇怪的事兒,第三方網(wǎng)站使用我們提供的簽名是出現(xiàn)了錯(cuò)誤,原因是使用php的urldecode時(shí)把加號(hào)(+) 替換成了空格
試驗(yàn)了一下python的urllib庫(kù)以及js 的 encodeURIComponent 均不會(huì)替換??崭馿ncode也是替換成了 '%20' 。python提供了urllib.quote_plus, urlib.unquote_plus來(lái)處理空格->加號(hào),看起來(lái)還是比較合理的。

查了一下 RFC 3986: 有下面一段

Scheme names consist of a sequence of characters beginning with a letter and followed by any combination of letters, digits, plus ("+"), period ("."), or hyphen ("-").
RFC 2396 有下面的一段

The plus "+", dollar "$", and comma "," characters have been added to those in the "reserved" set, since they are treated as reserved within the query component.
表示加號(hào)已經(jīng)是url的保留字了,不需要轉(zhuǎn)義。

然后html4文檔里才有關(guān)于加號(hào)的轉(zhuǎn)義:

application/x-www-form-urlencoded
Forms submitted with this content type must be encoded as follows:
Control names and values are escaped. Space characters are replaced by`+', and then reserved characters.....
聲明只有content-type為application/x-www-form-urlencoded時(shí)才會(huì)對(duì)+做轉(zhuǎn)義。

又翻了下php的文檔,發(fā)現(xiàn)有一個(gè)

rawurlencode() - URL-encode according to RFC 3986


也就是php又搞了rawurlencode和rawurldecode把標(biāo)準(zhǔn)實(shí)現(xiàn)了。。。。

不能反一下么,畢竟大部分人應(yīng)該都會(huì)用urlencode。php真是蛋疼啊。。。。

相關(guān)文章

最新評(píng)論