logo       

Re: cvs: pear /Net_URL URL.php: msg#00660

php.cvs.pear

Subject: Re: cvs: pear /Net_URL URL.php

Richard Heyes wrote:
Sorry about that. Do you have a problem with the patches?


I can't seem to reproduce any error with the URL you supplied
before the patch is applied.

That particular url returns data irregardless, so you do not get an error, but depending on the query string of a get method request, html or wsdl is returned, a very important distinction. The issue starts with the use of parse_str, which does not create any result of query_string == 'wsdl', and continues with the expectation that query string data is an array. However, my patch does not go far enough in fixing this issue. The query string 'xxx&yyy=2&zzz' would fail, resulting in a query string in the request being 'yyy=2'. Below is a patch to deal with this correctly (cleans up some whitespace also).

Regards,
Shane

diff -u -u -r1.17 URL.php
--- URL.php 29 Sep 2002 00:16:08 -0000 1.17
+++ URL.php 29 Sep 2002 20:11:44 -0000
@@ -244,13 +244,15 @@
if (!empty($this->querystring) &&
is_array($this->querystring)) {
foreach ($this->querystring as $name => $value) {
- if (is_array($value)) {
- foreach ($value as $k => $v) {
- $querystring[] =
sprintf('%s[%s]=%s', $name, $k, $v);
- }
- } else {
- $querystring[] = $name . '=' . $value;
- }
+ if (is_array($value)) {
+ foreach ($value as $k => $v) {
+ $querystring[] = sprintf('%s[%s]=%s', $name, $k, $v);
+ }
+ } else if (!is_null($value)) {
+ $querystring[] = $name . '=' . $value;
+ } else {
+ $querystring[] = $name;
+ }
}
$querystring = implode('&', $querystring);
} else {
@@ -269,21 +271,31 @@
*/
function _parseRawQuerystring($querystring)
{
- parse_str($querystring, $qs);
+ $this->parse_querystr($querystring, $qs);

- if (!$qs) return $querystring;
foreach ($qs as $key => $value) {
- if (is_array($value)) {
- foreach ($value as $k => $v) {
- $value[$k] = rawurlencode($v);
- }
- $qs[$key] = $value;
- } else {
- $qs[$key] = rawurlencode($value);
- }
+ if (is_array($value)) {
+ foreach ($value as $k => $v) {
+ $value[$k] = rawurlencode($v);
+ }
+ $qs[$key] = $value;
+ } else if (!is_null($value)) {
+ $qs[$key] = rawurlencode($value);
+ } else {
+ $qs[$key] = NULL;
+ }
}

return $qs;
+ }
+
+ function parse_querystr($querystring, &$result)
+ {
+ $parts = explode('&',$querystring);
+ foreach ($parts as $part) {
+ $nv = explode('=',$part);
+ $result[$nv[0]] = isset($nv[1])?$nv[1]:NULL;
+ }
}
}
?>




--
PEAR CVS Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise