Changeset 21622

Show
Ignore:
Timestamp:
10/19/08 15:52:09 (5 years ago)
Author:
lyokato
Message:

lang/perl/OAuth-Lite: Checking in changes prior to tagging of version 1.14. Changelog diff is:

Index: Changes
===================================================================
--- Changes (revision 21609)
+++ Changes (working copy)
@@ -1,5 +1,9 @@

Revision history for Perl extension OAuth::Lite.


+1.14 San Oct 19 15:37:00 2008
+ - Consumer and Util now can handle arrayref parameters for such as checkbox values.
+ Thanks to Evaldas Imbrasas.
+

1.13 Thu Oct 08 10:34:00 2008

  • Consumer now doesn't inherit LWP::UserAgent? but delegate.
  • Server::mod_perl2: fixed point that building regularized uri for proxy usage. borrowed code from Catalyst::Engine::Apache.
Location:
lang/perl/OAuth-Lite/trunk
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/OAuth-Lite/trunk/Changes

    r21027 r21622  
    11Revision history for Perl extension OAuth::Lite. 
     2 
     31.14  San Oct 19 15:37:00 2008 
     4    - Consumer and Util now can handle arrayref parameters for such as checkbox values. 
     5      Thanks to Evaldas Imbrasas. 
    26 
    371.13  Thu Oct 08 10:34:00 2008 
  • lang/perl/OAuth-Lite/trunk/lib/OAuth/Lite.pm

    r21027 r21622  
    44use warnings; 
    55 
    6 our $VERSION = "1.13"; 
     6our $VERSION = "1.14"; 
    77our $OAUTH_DEFAULT_VERSION = "1.0"; 
    88 
  • lang/perl/OAuth-Lite/trunk/lib/OAuth/Lite/Consumer.pm

    r21027 r21622  
    536536        $headers->header( Authorization => $header ); 
    537537        if (keys %$extra > 0) { 
    538             my $data = join('&', map(sprintf(q{%s=%s}, 
    539                 encode_param($_), encode_param($extra->{$_}) ), keys %$extra)); 
     538            my $data = normalize_params($extra); 
     539            #my $data = join('&', @extra_pairs); 
    540540            if (any { $method eq $_ } @send_data_methods) { 
    541541                $content = $data; 
     
    677677        map(sprintf(q{%s=%s}, encode_param($_), encode_param($all{$_})), 
    678678        keys %all)); 
    679     $query; 
     679    normalize_params({%all}); 
    680680} 
    681681 
  • lang/perl/OAuth-Lite/trunk/lib/OAuth/Lite/Util.pm

    r5043 r21622  
    1818    parse_auth_header 
    1919    build_auth_header 
     20    normalize_params 
    2021/]); 
    2122 
     
    112113    my ($method, $url, $params) = @_; 
    113114    $method = uc $method; 
     115    $params = {%$params}; 
     116    delete $params->{oauth_signature}; 
     117    delete $params->{realm}; 
    114118    my $normalized_request_url = normalize_request_url($url); 
    115119    my $normalized_params = normalize_params($params); 
     
    156160sub normalize_params { 
    157161    my $params = shift; 
    158     join('&', sort { $a cmp $b } 
    159         map(sprintf(q{%s=%s}, encode_param($_), encode_param($params->{$_})), 
    160         grep { $_ ne 'realm' && $_ ne 'oauth_signature' } keys %$params)); 
     162    my @pairs = (); 
     163    for my $k (keys %$params) { 
     164        if (!ref $params->{$k}) { 
     165            push @pairs,  
     166                sprintf(q{%s=%s}, encode_param($k), encode_param($params->{$k})); 
     167        } 
     168        elsif (ref $params->{$k} eq 'ARRAY') { 
     169            for my $v (@{ $params->{$k} }) { 
     170                push @pairs,  
     171                    sprintf(q{%s=%s}, encode_param($k), encode_param($v)); 
     172            } 
     173        } 
     174    } 
     175    return join('&', sort { $a cmp $b } @pairs); 
    161176} 
    162177 
     
    209224    my $authorization_header = join(', ', $head, 
    210225        sort { $a cmp $b } map(sprintf(q{%s="%s"}, encode_param($_), encode_param($params->{$_})), 
    211             grep { /^oauth_/ || /^xoauth_/ } keys %$params)); 
     226            grep { /^x?oauth_/ } keys %$params)); 
    212227    $authorization_header; 
    213228} 
  • lang/perl/OAuth-Lite/trunk/t/01_util.t

    r4630 r21622  
    1 use Test::More tests => 16; 
     1use Test::More tests => 18; 
    22 
    33use OAuth::Lite::Util; 
     
    5252is($parsed->{oauth_version},          '1.0'); 
    5353 
     54my $params_include_array = { 
     55        oauth_consumer_key     => 'dpf43f3p214k3103', 
     56        oauth_token            => 'nnch734d00s12jdk', 
     57        oauth_signature_method => 'HMAC-SHA1', 
     58        oauth_timestamp        => '1191242096', 
     59        oauth_nonce            => 'kllo9940pd9333jh', 
     60        oauth_version          => '1.0', 
     61        file                   => 'vacation.jpg', 
     62        size                   => 'original', 
     63    selected               => [ 1, 2, 3 ], 
     64}; 
    5465 
     66my $base2 = OAuth::Lite::Util::create_signature_base_string($http_method, $request_url, $params_include_array); 
     67is($base2, q{GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26oauth_consumer_key%3Ddpf43f3p214k3103%26oauth_nonce%3Dkllo9940pd9333jh%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00s12jdk%26oauth_version%3D1.0%26selected%3D1%26selected%3D2%26selected%3D3%26size%3Doriginal}); 
     68 
     69my $params_include_invalidtype = { 
     70        oauth_consumer_key     => 'dpf43f3p214k3103', 
     71        oauth_token            => 'nnch734d00s12jdk', 
     72        oauth_signature_method => 'HMAC-SHA1', 
     73        oauth_timestamp        => '1191242096', 
     74        oauth_nonce            => 'kllo9940pd9333jh', 
     75        oauth_version          => '1.0', 
     76        file                   => 'vacation.jpg', 
     77        size                   => 'original', 
     78    selected               => { unknown => 'type' }, 
     79}; 
     80 
     81my $base3 = OAuth::Lite::Util::create_signature_base_string($http_method, $request_url, $params_include_invalidtype); 
     82# throughed unknown type 
     83is($base3, q{GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26oauth_consumer_key%3Ddpf43f3p214k3103%26oauth_nonce%3Dkllo9940pd9333jh%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00s12jdk%26oauth_version%3D1.0%26size%3Doriginal}); 
     84