cvs: pear /Net_URL URL.php
| From: | Richard Heyes | Date: | Wed, 02 Mar 2005 03:42:23 +0000 |
| Subject: | cvs: pear /Net_URL URL.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-29988@lists.php.net to get a copy of this message | ||
richard Tue Mar 1 22:42:23 2005 EDT
Modified files:
/pear/Net_URL URL.php
Log:
Fix bug #2334
http://cvs.php.net/diff.php/pear/Net_URL/URL.php?r1=1.40&r2=1.41&ty=u
Index: pear/Net_URL/URL.php
diff -u pear/Net_URL/URL.php:1.40 pear/Net_URL/URL.php:1.41
--- pear/Net_URL/URL.php:1.40 Tue Mar 1 22:10:38 2005
+++ pear/Net_URL/URL.php Tue Mar 1 22:42:22 2005
@@ -32,7 +32,7 @@
// | Author: Richard Heyes <richard at php net> |
// +-----------------------------------------------------------------------+
//
-// $Id: URL.php,v 1.40 2005/03/02 03:10:38 richard Exp $
+// $Id: URL.php,v 1.41 2005/03/02 03:42:22 richard Exp $
//
// Net_URL Class (PHP5 Only)
@@ -257,6 +257,10 @@
{
if (!empty($this->querystring)) {
foreach ($this->querystring as $name => $value) {
+
+ // Encode var name
+ $name = rawurlencode($name);
+
if (is_array($value)) {
foreach ($value as $k => $v) {
$querystring[] = $this->useBrackets ? sprintf('%s[%s]=%s',
$name, $k, $v) : ($name . '=' . $v);
@@ -368,14 +372,26 @@
$value = null;
$key = $part;
}
- if (substr($key, -2) == '[]') {
- $key = substr($key, 0, -2);
+
+ $key = rawurldecode($key);
+
+ if (preg_match('#^(.*)\[([0-9a-z_-]*)\]#i', $key, $matches)) {
+ $key = $matches[1];
+ $idx = $matches[2];
+
+ // Ensure is an array
if (empty($return[$key]) || !is_array($return[$key])) {
- $return[$key] = array();
+ $return[$key] = array();
+ }
+
+ // Add data
+ if ($idx === '') {
$return[$key][] = $value;
+
} else {
- $return[$key][] = $value;
+ $return[$key][$idx] = $value;
}
+
} elseif (!$this->useBrackets AND !empty($return[$key])) {
$return[$key] = (array)$return[$key];
$return[$key][] = $value;