From 1797397f158e8c143c816ba14aac2e712609ff23 Mon Sep 17 00:00:00 2001 From: David Cook Date: Wed, 17 Jun 2020 04:17:06 +0000 Subject: [PATCH] Bug 25774: replace decode_json with from_json decode_json expects octets/bytes but from_json expects a string. We don't need to encode the query parameters as bytes to give to decode_json. Instead, we can just pass the string to from_json, and it will work as expected. --- Koha/REST/Plugin/Objects.pm | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Koha/REST/Plugin/Objects.pm b/Koha/REST/Plugin/Objects.pm index 47c2659cce..e313ea87f9 100644 --- a/Koha/REST/Plugin/Objects.pm +++ b/Koha/REST/Plugin/Objects.pm @@ -19,8 +19,7 @@ use Modern::Perl; use Mojo::Base 'Mojolicious::Plugin'; -use JSON qw(decode_json); -use Encode qw(encode_utf8); +use JSON qw(from_json); =head1 NAME @@ -105,8 +104,8 @@ sub register { my @query_params_array; my $query_params; push @query_params_array, $reserved_params->{query} if defined $reserved_params->{query}; - push @query_params_array, decode_json(encode_utf8 $reserved_params->{q}) if defined $reserved_params->{q}; - push @query_params_array, decode_json(encode_utf8 $reserved_params->{'x-koha-query'}) if defined $reserved_params->{'x-koha-query'}; + push @query_params_array, from_json($reserved_params->{q}) if defined $reserved_params->{q}; + push @query_params_array, from_json($reserved_params->{'x-koha-query'}) if defined $reserved_params->{'x-koha-query'}; if(scalar(@query_params_array) > 1) { $query_params = {'-and' => \@query_params_array}; -- 2.11.0