php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61444 http_build_url with HTTP_URL_JOIN_QUERY converts . to _ in param names
Submitted: 2012-03-19 20:04 UTC Modified: 2012-04-04 10:37 UTC
From: signe at cothlamadh dot net Assigned: mike (profile)
Status: Wont fix Package: pecl_http (PECL)
PHP Version: 5.3.10 OS: Ubuntu 11.10
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: signe at cothlamadh dot net
New email:
PHP Version: OS:

 

 [2012-03-19 20:04 UTC] signe at cothlamadh dot net
Description:
------------
pecl_http version 1.7.3

http_build_url() replaces "." in query string parameter names with "_" when using the HTTP_URL_JOIN_QUERY option.

This behavior is different than http_build_string() which does not perform this replacement, and the replacement does not occur when replacing the query string entirely.

Test script:
---------------
$url = 'http://www.example.com/foobar?bar.baz=blah&utm_source=google&utm_campaign=somethingelse&blat';

// Original
echo $url, PHP_EOL, PHP_EOL;

// Changing a parameter in the string
echo http_build_url($url, array('query' => 'utm_source=changed'), HTTP_URL_JOIN_QUERY), PHP_EOL, PHP_EOL;

// Replacing the host
echo http_build_url($url, array('host' => 'www.google.com')), PHP_EOL, PHP_EOL;

// Generating a query string from scratch
echo http_build_str(array(
            'bar.baz' => 'blah',
            'utm_source' => 'google',
            'utm_campaign' => 'somethingelse',
            'blat' => null,
            )), PHP_EOL, PHP_EOL;


Expected result:
----------------
// Original
http://www.example.com/foobar?bar.baz=blah&utm_source=google&utm_campaign=somethingelse&blat

// bar.baz should be as originally entered, 'utm_source' updated with new value
http://www.example.com/foobar?bar.baz=blah&utm_source=changed&utm_campaign=somethingelse&blat=

// Host replaced, query string untouched
http://www.google.com/foobar?bar.baz=blah&utm_source=google&utm_campaign=somethingelse&blat

// Query string replaced as-is, no . conversion
http://www.example.com/foobar?blah.foo=baz

// Query string generated, no . conversion
bar.baz=blah&utm_source=google&utm_campaign=somethingelse&blat=

Actual result:
--------------
// Original
http://www.example.com/foobar?bar.baz=blah&utm_source=google&utm_campaign=somethingelse&blat

// BUGBUG: utm_source updated, but bar.baz (which was not touched in the parameters) was replaced with bar_baz
http://www.example.com/foobar?bar_baz=blah&utm_source=changed&utm_campaign=somethingelse&blat=

// Host replaced, query string untouched
http://www.google.com/foobar?bar.baz=blah&utm_source=google&utm_campaign=somethingelse&blat

// Query string replaced as-is, no . conversion
http://www.example.com/foobar?blah.foo=baz

// Query string generated, no . conversion
bar.baz=blah&utm_source=google&utm_campaign=somethingelse&blat=

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-04-01 19:25 UTC] mike@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: mike
 [2012-04-04 10:37 UTC] mike@php.net
Won't fix for v1, sorry.

Fixed in v2, though.
 [2012-04-04 10:37 UTC] mike@php.net
-Status: Assigned +Status: Wont fix
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Nov 05 07:01:29 2024 UTC