Home » Networking » Net_URL » Bug #704
Hardcoded & instead of ini_get('arg_separator.xxx')
Details
| Submitted | 2004-02-07 14:51 UTC |
|---|---|
| From | miancule at yahoo dot com |
| Assigned | richard |
| Status | Closed |
| Package | Net_URL |
| PHP Version | 4.3.4 |
| OS | Windows 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 '&'.