Skip to content
This repository was archived by the owner on Apr 23, 2025. It is now read-only.

Commit a6707dc

Browse files
committed
Fix update_with_media with utf8 status (RT#72814)
1 parent 5684714 commit a6707dc

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

lib/Net/Twitter/Core.pm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,9 @@ sub _prepare_request {
175175
$msg = (first { ref } values %natural_args)
176176
? POST($uri,
177177
Content_Type => 'form-data',
178-
Content => \%natural_args,
178+
Content => [
179+
map { ref $_ ? $_ : encode_utf8 $_ } %natural_args,
180+
],
179181
)
180182
: POST($uri, Content => $self->_query_string_for(\%natural_args))
181183
;

t/unicode.t

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ use Net::Twitter;
99
eval "use LWP::UserAgent 5.819";
1010
plan skip_all => 'LWP::UserAgent >= 5.819 required' if $@;
1111

12-
plan tests => 12;
12+
plan tests => 13;
1313

1414
my $req;
1515
my $ua = LWP::UserAgent->new;
1616
$ua->add_handler(request_send => sub {
1717
$req = shift;
18-
return HTTP::Response->new(200);
18+
my $res = HTTP::Response->new(200);
19+
$res->content('{}');
20+
return $res;
1921
});
2022

2123
sub raw_sent_status {
@@ -95,3 +97,20 @@ is sent_status(), $status, 'basic auth';
9597

9698
try { $nt->update($latin1) };
9799
is sent_status(), $latin1, 'latin-1 basic auth';
100+
101+
############################################################
102+
# update_with_media
103+
############################################################
104+
try {
105+
my $r = $nt->update_with_media($status, [
106+
undef, undef,
107+
content_type => 'image/png',
108+
content => 'image-data',
109+
]);
110+
111+
pass 'update_image_with_media';
112+
}
113+
catch {
114+
fail $_;
115+
};
116+

0 commit comments

Comments
 (0)