Subject: | update_status does not support non-ASCII characters |
Date: | Mon, 11 Jan 2010 03:15:04 +0900 |
To: | bug-anyevent-twitter [...] rt.cpan.org |
From: | 山村 英貴 <hideki.yamamura [...] gmail.com> |
Thanks for this very useful module.
I found a bug about handling utf8 strings.
The bug is that update_status does not support non-ASCII characters.
First, this module use common::sense, so it implies "use utf8".
In update_status(), $url->query_form is called with two arguments:
(status, $status_e)
key:status is utf8-flagged, but val:$status_e is octets.
So in URI::_query::query_form, $status_e will be converted to utf8
when those key & val are connected.
But $status_e is already converted to utf-8, so posted update turns
unreadable strings
when $status contained non-ASCII characters (like CJK, etc).
--- /usr/lib/perl5/site_perl/5.8.8/AnyEvent/Twitter.pm 2009-11-05
08:09:54.000000000 +0900
+++ ./lib/AnyEvent/Twitter.pm 2010-01-11 03:03:21.000000000 +0900
@@ -477,11 +477,9 @@
sub update_status {
my ($self, $status, $done_cb) = @_;
- my $status_e = _encode_status $status;
-
my $url = URI::URL->new ($self->{base_url});
$url->path_segments ('statuses', "update.json");
- $url->query_form (status => $status_e);
+ $url->query_form (status => decode_utf8($status));
my $hdrs = { $self->_get_basic_auth };