url decode problem 解决方法

yipeiwu_com6年前PHP代码库
试验了一下python的urllib库以及js 的 encodeURIComponent 均不会替换。空格encode也是替换成了 '%20' 。python提供了urllib.quote_plus, urlib.unquote_plus来处理空格->加号,看起来还是比较合理的。

查了一下 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.
表示加号已经是url的保留字了,不需要转义。

然后html4文档里才有关于加号的转义:

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时才会对+做转义。

又翻了下php的文档,发现有一个

rawurlencode() - URL-encode according to RFC 3986


也就是php又搞了rawurlencode和rawurldecode把标准实现了。。。。

不能反一下么,毕竟大部分人应该都会用urlencode。php真是蛋疼啊。。。。

相关文章

coreseek 搜索英文的问题详解

问题描述: 被搜索名字为:andy 这时搜索andy正常,但是搜索a就搜不到。 解决办法,在索引配置文件中的index中添加min_infix_len = 1最后还要重新索引一下/usr...

PHP7.1方括号数组符号多值复制及指定键值赋值用法分析

本文实例讲述了PHP7.1方括号数组符号多值复制及指定键值赋值用法。分享给大家供大家参考,具体如下: PHPer 们可能都知道 list 的用法,简单来说就是可以在一个表达试里通过数组对...

thinkphp 多表 事务详解

如下所示:复制代码 代码如下:function makeAcquire($nUsers,$nAwards)    {    &...

不常用但很实用的PHP预定义变量分析

1. $php_errormsg — 前一个错误信息 <?php @strpos(); echo $php_errormsg; ?> 2.$htt...

php英文单词统计器

php英文单词统计器

本文实例为大家分享了英文单词统计器php 实现,供大家参考,具体内容如下 程序开始运行, 按"浏览"钮选择一个英文文档, 再按"统计 Statistics"钮, 即可得到按字母顺序列出的...