Changeset 21622
- Timestamp:
- 10/19/08 15:52:09 (5 years ago)
- Location:
- lang/perl/OAuth-Lite/trunk
- Files:
-
- 5 modified
-
Changes (modified) (1 diff)
-
lib/OAuth/Lite.pm (modified) (1 diff)
-
lib/OAuth/Lite/Consumer.pm (modified) (2 diffs)
-
lib/OAuth/Lite/Util.pm (modified) (4 diffs)
-
t/01_util.t (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/OAuth-Lite/trunk/Changes
r21027 r21622 1 1 Revision history for Perl extension OAuth::Lite. 2 3 1.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. 2 6 3 7 1.13 Thu Oct 08 10:34:00 2008 -
lang/perl/OAuth-Lite/trunk/lib/OAuth/Lite.pm
r21027 r21622 4 4 use warnings; 5 5 6 our $VERSION = "1.1 3";6 our $VERSION = "1.14"; 7 7 our $OAUTH_DEFAULT_VERSION = "1.0"; 8 8 -
lang/perl/OAuth-Lite/trunk/lib/OAuth/Lite/Consumer.pm
r21027 r21622 536 536 $headers->header( Authorization => $header ); 537 537 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); 540 540 if (any { $method eq $_ } @send_data_methods) { 541 541 $content = $data; … … 677 677 map(sprintf(q{%s=%s}, encode_param($_), encode_param($all{$_})), 678 678 keys %all)); 679 $query;679 normalize_params({%all}); 680 680 } 681 681 -
lang/perl/OAuth-Lite/trunk/lib/OAuth/Lite/Util.pm
r5043 r21622 18 18 parse_auth_header 19 19 build_auth_header 20 normalize_params 20 21 /]); 21 22 … … 112 113 my ($method, $url, $params) = @_; 113 114 $method = uc $method; 115 $params = {%$params}; 116 delete $params->{oauth_signature}; 117 delete $params->{realm}; 114 118 my $normalized_request_url = normalize_request_url($url); 115 119 my $normalized_params = normalize_params($params); … … 156 160 sub normalize_params { 157 161 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); 161 176 } 162 177 … … 209 224 my $authorization_header = join(', ', $head, 210 225 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)); 212 227 $authorization_header; 213 228 } -
lang/perl/OAuth-Lite/trunk/t/01_util.t
r4630 r21622 1 use Test::More tests => 1 6;1 use Test::More tests => 18; 2 2 3 3 use OAuth::Lite::Util; … … 52 52 is($parsed->{oauth_version}, '1.0'); 53 53 54 my $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 }; 54 65 66 my $base2 = OAuth::Lite::Util::create_signature_base_string($http_method, $request_url, $params_include_array); 67 is($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 69 my $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 81 my $base3 = OAuth::Lite::Util::create_signature_base_string($http_method, $request_url, $params_include_invalidtype); 82 # throughed unknown type 83 is($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
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)