Bug #72617 [Fbk->Nab]: http_build_query http_build_query incorrectly converts a string

From: Date: Mon, 18 Jul 2016 19:23:41 +0000
Subject: Bug #72617 [Fbk->Nab]: http_build_query http_build_query incorrectly converts a string
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-202407@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72617&edit=1

 ID:                 72617
 Updated by:         cmb@php.net
 Reported by:        htc dot tolya at gmail dot com
 Summary:            http_build_query http_build_query incorrectly
                     converts a string
-Status:             Feedback
+Status:             Not a bug
 Type:               Bug
 Package:            *URL Functions
 Operating System:   ANY
 PHP Version:        Irrelevant
 Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php

> if (arg_separator.output = "&") conversion is not correct!

Of course, the conversion is correct. But if you're printing the
value in an HTML (or XML) document, you have to escape special
characters (e.g. by using htmlspecialchars()).


Previous Comments:
------------------------------------------------------------------------
[2016-07-18 19:00:39] htc dot tolya at gmail dot com

if (arg_separator.output = "& amp;") the correct transformation is present in the
address &
if (arg_separator.output = "&") conversion is not correct!
but this is not a recipe because the address used file_get_contents and similar functions, and
&amp does not work there

------------------------------------------------------------------------
[2016-07-18 18:45:52] cmb@php.net

Usually, this should work fine, see <https://3v4l.org/KS61j>.

What is the value of your ini setting of arg_separator.output[1]?
What is your locale?

[1] <http://php.net/manual/en/ini.core.php#ini.arg-separator.output>

------------------------------------------------------------------------
[2016-07-18 17:18:05] htc dot tolya at gmail dot com

Description:
------------
http_build_query incorrectly converts a string.

Example.

$url = 'http://site.com/action?';
$url .= http_build_query([
  'param1' => 10,
  'region' => 'en'
]);

P.S>Setting arg_separator (& amp) solves the problem, but this approach does not in all
cases.



Test script:
---------------
$url = 'http://site.com/action?';
$url .= http_build_query([
  'param1' => 10,
  'region' => 'en'
]);
echo $url;

Expected result:
----------------
http://site.com/action?param1=10&region=en

Actual result:
--------------
http://site.com/action?param1=10®ion=en


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



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


Thread (4 messages)

« previous php.bugs (#202407) next »