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真是蛋疼啊。。。。

相关文章

一个PHP模板,主要想体现一下思路

思路: 欲在速度和易用(主要指的是美工设计的方便性)之间取得一个平衡点.于是采用了由html文件生成php文件的办法(编译?) 也想在分离显示逻辑和分离html代码之间平衡一下 例如一个...

PHP文件上传操作实例详解

PHP文件上传操作实例详解

本文实例分析了PHP文件上传操作。分享给大家供大家参考,具体如下: 文件上传 发生在浏览器向服务器发出的请求中。 文件,对于浏览器来讲,就是表单中的一个特殊类型的数据而已。 浏览器表单中...

session在php5.3中的变化 session_is_registered() is deprecated in

在php5.3中运行书中代码会有如下提示:Function session_is_registered() is deprecated inFunction session_regist...

深入探究PHP的多进程编程方法

子进程的创建 一般的子进程的写法是: <?php $pid = pcntl_fork(); if($pid == -1){ //创建失败 die('...

PHP的几个常用数字判断函数代码

复制代码 代码如下: <HTML> <HEAD> <TITLE>常用的数值判断函数</TITLE> </HEAD> <B...