Bug #80277 [Com]: parse_url & parse_str problems with values with percentage

From: Date: Fri, 23 Oct 2020 15:42:36 +0000
Subject: Bug #80277 [Com]: parse_url & parse_str problems with values with percentage
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-229887@lists.php.net to get a copy of this message
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:             Open
 Type:               Bug
 Package:            URL related
 Operating System:   Debian 10
 PHP Version:        7.4.11
 Block user comment: N
 Private report:     N

 New Comment:

Of course, it is nonsense if you need to convert "%" but nothing else. Where did you have
this in the documentation of parse_url? Or should we have some glass sphere to predict it? For me,
it is a nonsense behavior of a function and of course a BUG!


Previous Comments:
------------------------------------------------------------------------
[2020-10-23 15:33:09] cmb@php.net

> But this makes nonsense!

If you say so.

------------------------------------------------------------------------
[2020-10-23 15:22:34] nnikolay at gmail dot com

But this makes nonsense! Why should I convert the "%" to "%25" before I gave it
to the function parse_url? Why the function parse_url & parse_str do not make it? If this is so,
why I should not convert "&" to "%26" and all the other characters?

------------------------------------------------------------------------
[2020-10-23 15:09:54] cmb@php.net

Percent characters in an URI introduce a percent-encoded[1]
character, and parse_url() and parse_str() interpret it as such.
A literal percent character would have to be written as %25 in an
URI, see <https://3v4l.org/2C3Bo>.


[1] <https://en.wikipedia.org/wiki/Percent-encoding>

------------------------------------------------------------------------
[2020-10-23 14:37:07] nnikolay at gmail dot com

Description:
------------
parse_url & parse_str have problems, when in the URL is some value with percent in the form:

domain.com/?campaignid=%campaignid%&adid=%bannerid%

Then both of them are converting the "%" in some unicode, which breaks the code:

array(4) {
  ["scheme"]=>
  string(5) "https"
  ["host"]=>
  string(19) "domain"
  ["path"]=>
  string(16) "/path/"
  ["query"]=>
  array(6) {
    ["campaignid"]=>
    string(10) "�mpaignid%"
    ["adid"]=>
    string(8) "�nnerid%"
  }
} 



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=80277&edit=1


Thread (13 messages)

« previous php.bugs (#229887) next »