Skip to content

Commit

Permalink
Correctly handle non utf8 characters
Browse files Browse the repository at this point in the history
  • Loading branch information
mickenordin authored Sep 22, 2016
1 parent 1e62ec1 commit e7dba1d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion SU/API/Icinga2.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use LWP::UserAgent;
use HTTP::Request;
use URI::Escape;
use JSON;
use Encode qw( encode_utf8 );

sub new {
my $class = shift;
Expand Down Expand Up @@ -58,7 +59,8 @@ sub do_request {
if (!$self->{res}->is_success) {
return undef;
};
my $json_result = decode_json($self->{res}->content);
# Handle non utf8 chars
my $json_result = decode_json(encode_utf8($self->{res}->content));

if ($json_result) {
return $json_result;
Expand Down

0 comments on commit e7dba1d

Please sign in to comment.