Home > Backend Development > PHP Tutorial > url decode problem solution_PHP tutorial

url decode problem solution_PHP tutorial

WBOY
Release: 2016-07-21 15:21:41
Original
947 people have browsed it

After testing python's urllib library and js's encodeURIComponent, they will not be replaced. Space encode is also replaced with '%20'. Python provides urllib.quote_plus, urlib.unquote_plus to handle spaces->plus signs, which seems reasonable.

I checked RFC 3986: there is the following paragraph

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 has the following paragraph

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.
means that the plus sign is already a reserved word of the URL and does not need to be escaped.

Then there is the escape of the plus sign in the html4 document:

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.....
Declare + only when content-type is application/x-www-form-urlencoded Do escaping.

Looking through the php documentation again, I found a

rawurlencode() - URL-encode according to RFC 3986


That is, php has done rawurlencode again and rawurldecode implement the standard. . . .

Can’t you reverse it? After all, most people should be able to use urlencode. php is such a pain in the ass. . . .

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/324845.htmlTechArticleAfter testing the urllib library of python and the encodeURIComponent of js, they will not be replaced. Space encode is also replaced with '%20'. python provides urllib.quote_plus, urlib.unquote_plus to handle...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template