PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Networking » Net_URL » Bug #704

Hardcoded & instead of ini_get('arg_separator.xxx')

Details

Submitted2004-02-07 14:51 UTC
Frommiancule at yahoo dot com
Assignedrichard
StatusClosed
PackageNet_URL
PHP Version4.3.4
OSWindows XP
Roadmaps(Not assigned)

Comments

[2004-02-07 14:51 UTC] miancule at yahoo dot com

Description:
------------
A small thing, but essential for XHTML compliancy (& instead of & in URLs), etc

Instead of using harcoded & as argument separator, the code should use ini_get('arg_separator.input') and ini_get('arg_separator.output').

Changes to URL.php:

Line 272:
$querystring = implode('&', $querystring);
becomes:
$querystring = implode(ini_get('arg_separator.output'), $querystring);

Line 289:
$parts = preg_split('/&/', $querystring, -1, PREG_SPLIT_NO_EMPTY);
becomes:
$parts = preg_split('/'.preg_quote(ini_get('arg_separator.input'),'/').'/', $querystring, -1, PREG_SPLIT_NO_EMPTY);

Regards,
mihai

Reproduce code:
---------------
<?php
ini_set('arg_separator.output', '&');

require_once 'Net/URL.php';

$url = &new NetURL('http://foo.bar/index.php');
$url->addQueryString('apples', 5);
$url->addQueryString('oranges', 15);

echo $url->getURL();
die;
?>

Expected result:
----------------
The output of the $url->getURL() call should be:
http://foo.bar/index.php?apples=5&oranges=15

Actual result:
--------------
The output of the $url->getURL() call is:
http://foo.bar/index.php?apples=5&oranges=15

[2004-05-08 17:32 UTC] richard at phpguru dot org

Thank you for your bug report. This issue has been fixed
in the latest released version of the package, which you can download at
http://pear.php.net/packages.php

[2004-09-02 21:27 UTC] joern_h at gmx dot net

I think the value of arg_separator.output should not be used since its a setting that applies to the server the script is running on. If you connect to a different server it may need a different separator. Perhaps the separator should be settable by a method and default to '&'.