File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -74,15 +74,23 @@ sub request {
7474 return $req ;
7575}
7676
77+ my $encoding = Encode::find_encoding(' utf-8-strict' )
78+ or warn ' UTF-8 Encoding object not found' ;
79+ my $encode_check = ( Encode::FB_CROAK | Encode::LEAVE_SRC );
80+
7781sub raw_api_response {
7882 my ($self , $data ) = @_ ;
7983
84+ # will http_response ever return undef or a blessed object?
85+ $data = ' ' if ! defined $data ; # define
86+ $data .= ' ' if ref $data ; # stringify
87+
8088 # we have to assume an encoding; doing nothing is like assuming latin1
8189 # we'll probably have the least number of issues if we assume utf8
8290 local $@ ;
8391 eval {
8492 # decode so the template doesn't double-encode and return mojibake
85- $data = Encode:: decode(' UTF-8 ' , $data , Encode::FB_CROAK );
93+ $data &&= $encoding -> decode( $data , $encode_check );
8694 };
8795 warn $@ if $@ ;
8896
You can’t perform that action at this time.
0 commit comments