Skip Menu |
 

This queue is for tickets about the Net-OAuth CPAN distribution.

Report information
The Basics
Id: 73705
Status: new
Priority: 0/
Queue: Net-OAuth

People
Owner: Nobody in particular
Requestors: tomaz.solc [...] tablix.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.27
Fixed in: (no value)



Subject: breaks with "use encoding" and non-ascii characters
Download (untitled) / with headers
text/plain 1.2k
Hi It appears that Net::OAuth doesn't work correctly when called from a script that uses the 'encoding' pragma. It will fail with the following message whenever non-ASCII characters are present: Net::OAuth warning: your OAuth message appears to contain some multi-byte characters that need to be decoded via Encode.pm or a PerlIO layer first. This may result in an incorrect signature. at Net-OAuth-0.27/lib/Net/OAuth/Message.pm line 106. Note that I'm passing decoded, wide-character strings, not strings containing utf8 encoded multi-byte characters as the error message suggests. You can reproduce this using the script I attached (requires Net::Twitter::Lite), or by adding "use encoding 'utf8'" at the top of the t/09-encoding.t unit test. I'm also attaching a patch that seems to fix this. It appears the combination of '^\w.~-' and 'encoding' pragma breaks uri_escape_utf8() so that it will let through non-ascii characters, although I can't explain why exactly. It might even be a bug in uri_escape_utf8() as just '^\w' does the right thing, as does '^A-Za-z0-9'. According to the URI::Escape documentation the '\w.~-' argument is equal to the default one anyway, so I don't see any harm in removing it. Regards Tomaž
Subject: uri_escape_utf8_encode.patch
Index: Net-OAuth-0.27/lib/Net/OAuth/Message.pm =================================================================== --- Net-OAuth-0.27.orig/lib/Net/OAuth/Message.pm 2012-01-03 15:55:45.000000000 +0100 +++ Net-OAuth-0.27/lib/Net/OAuth/Message.pm 2012-01-03 15:55:52.000000000 +0100 @@ -106,7 +106,7 @@ warn "Net::OAuth warning: your OAuth message appears to contain some multi-byte characters that need to be decoded via Encode.pm or a PerlIO layer first. This may result in an incorrect signature."; } } - return URI::Escape::uri_escape_utf8($str,'^\w.~-'); + return URI::Escape::uri_escape_utf8($str); } sub decode {
Subject: uri_escape_utf8_encode.pl
use encoding 'utf8'; use Net::Twitter::Lite; my $text = "\x{10d}\x{17e}\x{161}"; my $nt = Net::Twitter::Lite->new( consumer_key => 'xxx', consumer_secret => 'xxx' ); $nt->access_token('xxx'); $nt->access_token_secret('xxx'); die "Not authorized" unless $nt->authorized; my $result = eval { $nt->update($text) }; if ($@) { if ($@->isa('Net::Twitter::Lite::Error')) { warn $@->error; } else { die $@; } }


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.