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函数rtrim()使用中的怪异现象分析

本文实例讲述了PHP函数rtrim()使用中的怪异现象。分享给大家供大家参考,具体如下: 今天用rtrim()函数时遇到了一个奇怪的问题: echo rtrim('<p>...

快速解决PHP调用Word组件DCOM权限的问题

快速解决PHP调用Word组件DCOM权限的问题

1. 首先必须要在电脑上安装 Office 2. windows+r : 输入 dcomcnfg.exe 打开组件服务,然后双击 组件服务 ==> 双击 计算机 ==> 双击...

PHP ADODB实现分页功能简单示例

PHP ADODB实现分页功能简单示例

本文实例讲述了PHP ADODB实现分页功能。分享给大家供大家参考,具体如下: 一、代码 adodb.inc.php可从官方网站http://adodb.sourceforge.net/...

php_screw 1.5:php加密: 安装与使用详解

php文件通常以文本格式存贮在服务器端, 很容易被别人读到源代码, 为了对源代码进行保护, 可以采用对源代码进行加密的方式.要实现该功能需要两部分:一是加密程序,实现对PHP文件的加密....

用PHP代码在网页上生成图片

用PHP代码在网页上生成图片

代码很简单,这里就不多废话了, <?php /** * Created by PhpStorm. * User: Administrator * Date: 2...