Edit report at https://bugs.php.net/bug.php?id=80277&edit=1
ID: 80277
Comment by: nnikolay at gmail dot com
Reported by: nnikolay at gmail dot com
Summary: parse_url & parse_str problems with values with
percentage
Status: Not a bug
Type: Bug
Package: URL related
Operating System: Debian 10
PHP Version: 7.4.11
Block user comment: N
Private report: N
New Comment:
Guys I don't want to speak with the whole php.net team about this unexpected behavior. When
only "%" is a special character and everyone, who is starting to develop with PHP needs to
learn every one of the RFC standards, then you need some break. The function parse_str() expects an
$encoded_string, but there should be only "%" encoded - very helpful? How should someone
know this, if not experiment with it and lose hours?
Here the example: https://3v4l.org/oPCf5 with your docu
suggestion for parse_str ( string $encoded_string [, array &$result ] ) : void
You can tell me everything, but the documentation is not clear and it is not clear, that we need to
encode only "%" to "%25".
Previous Comments:
------------------------------------------------------------------------
[2020-10-23 19:07:49] eveg at ldbdh dot com
it's not the job of the docs for a programing language to educate you about absolute BASICS of
the data you work with
------------------------------------------------------------------------
[2020-10-23 18:58:45] requinix@php.net
parse_url does not parse the query string. It will return
"campaignid=%campaignid%&adid=%bannerid%".
parse_str *does* parse the query string. And the docs already say
> Note:> All variables created (or values returned into array if second parameter is set)> are already urldecode()d.
------------------------------------------------------------------------
[2020-10-23 18:40:29] nnikolay at gmail dot com
Super! Then add it please here: https://www.php.net/manual/en/function.parse-url.php
and save next time someone half a day to look for a solution because if this is expected, it should
be documented at the right place.
------------------------------------------------------------------------
[2020-10-23 18:35:30] girgias@php.net
% has special semantics in URL see:
>>> In addition, octets may be encoded by a character triplet consisting
of the character "%" followed by the two hexadecimal digits (from
"0123456789ABCDEF") which forming the hexadecimal value of the octet.
(The characters "abcdef" may also be used in hexadecimal encodings.)
Source: Section 2.2. URL Character Encoding Issues of RFC 1738 - Uniform Resource Locators (URL)
http://www.faqs.org/rfcs/rfc1738.html
------------------------------------------------------------------------
[2020-10-23 18:22:12] nnikolay at gmail dot com
Then do something and comment it on your docu page before trying to make the other people clueless.
If it's in the docu it is ok and makes sense, if not it is unexpected behavior and in each
language, it is a BUG. Only because you think to know it, means not, that other people need to try
all the variations of some function and to see what would be the results.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=80277
--
Edit this bug report at https://bugs.php.net/bug.php?id=80277&edit=1