Hi Robin
Right - forgot about that case..
Basically what you're doing is turning $param['key1']['key2']..
['keyN'] into $param['key1[key2]..[keyN]] - is that correctly
understood?
In that case, wouldn't it be easier to just always apply this to all
of $params earlier on, seeing how it wouldn't break any existing
functionality only add more for free?
I will probably create a new branch with a few more (or maybe only
one) of my outstanding and your patches, then we can run it though the
code-review process and get it merged into trunk..
It might not be till tomorrow or in a few days though.. work and
college is keeping me busy..
If you have any questions you can also hit me up at #oauth
(irc://irc.freenode.org
#oauth)
Regards
Morten
On Mar 9, 2009, at 3:40 PM, Robin Gareus wrote:
> Hello again,
>
> I was pleased to see the termie-fangle branch got merged into trunk.
> It fixes many issues, however query-parameter-arrays are still not
> supported in the oauth PHP lib.
> The attached patch resolves this issue; it'd be great if you can
> review and merge it.
>
> cheers,
> robin
>
> PS.
> Here's an example:
> URL: ...?do[oauth]=requesttoken
> base-url: do%5Boauth%5D=requesttoken&oauth_...
> base-string: ...&do%255Boauth%255D%3Drequesttoken%26oauth_...
>
> The OAuth PHP lib SVN r908 neglects the array key and computes a wrong
> base-url: &do%3Drequesttoken%26oauth_...
> The http_url:private of OAauth.php is correct:
> ...?do%5Boauth%5D=requesttoken&...
>
> FWIW: I've also tested attached patch with multidimensional arrays:
> eg. ?test[1][2][3]=4
>
> >
> --- /home/rgareus/src/svn/oauth/code/php/OAuth.php 2009-03-09
> 15:28:30.000000000 +0100
> +++ OAuth.php 2009-03-09 15:28:11.000000000 +0100
> @@ -245,6 +245,17 @@
> return $this->parameters;
> }/*}}}*/
>
> + private function recurse_param_array($params, $k, $v) {/*{{{*/
> + foreach($v as $ak => $av) {
> + if (is_array($av)) {
> + $this->recurse_param_array(&$params, $k.'['.$ak.']', $av);
> + } else {
> + $params[$k.'['.$ak.']']=$av;
> + }
> + }
> + return $params;
> + }/*}}}*/
> +
> /**
> * Returns the normalized parameters of the request
> *
> @@ -265,10 +276,17 @@
> if (isset($params['oauth_signature'])) {
> unset($params['oauth_signature']);
> }
> +
> + foreach($params as $k => $v) {
> + if (is_array($v)) {
> + unset($params[$k]);
> + $this->recurse_param_array(&$params, $k, $v);
> + }
> + }
>
> // Urlencode both keys and values
> - $keys = OAuthUtil::urlencode_rfc3986(array_keys($params));
> - $values = OAuthUtil::urlencode_rfc3986(array_values($params));
> + $keys = array_map(array('OAuthUtil', 'urlencode_rfc3986'),
> array_keys($params));
> + $values = array_map(array('OAuthUtil', 'urlencode_rfc3986'),
> array_values($params));
> $params = array_combine($keys, $values);
>
> // Sort by keys (natsort)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"OAuth" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/oauth?hl=en
-~----------~----~----~----~------~----~------~--~---