Edit report at https://bugs.php.net/bug.php?id=80277&edit=1
ID: 80277
Comment by: djrhr at rgegez 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:
it's only unexpected for YOU the same way as others don't realize that they have to encode
& as & in a html link and just because everything works most of the time don't mean
that specifications don't matter
stop whining and do your homework
Previous Comments:
------------------------------------------------------------------------
[2020-10-23 19:22:50] nnikolay at gmail dot com
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".
------------------------------------------------------------------------
[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
------------------------------------------------------------------------
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