Bugzilla – Attachment 168176 Details for
Bug 37157
Error 500 when loading identity provider list
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37157: Fix Malformed UTF-8 character in JSON string before decode_json
Bug-37157-Fix-Malformed-UTF-8-character-in-JSON-st.patch (text/plain), 4.06 KB, created by
Nick Clemens (kidclamp)
on 2024-06-26 18:38:49 UTC
(
hide
)
Description:
Bug 37157: Fix Malformed UTF-8 character in JSON string before decode_json
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2024-06-26 18:38:49 UTC
Size:
4.06 KB
patch
obsolete
>From b561bb026332b9c36a99dfa2e8613f4bbc21c0c1 Mon Sep 17 00:00:00 2001 >From: Hammat Wele <hammat.wele@inlibro.com> >Date: Fri, 21 Jun 2024 17:07:47 +0000 >Subject: [PATCH] Bug 37157: Fix Malformed UTF-8 character in JSON string > before decode_json >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >When we add a new identity provider and put some special characters in the Config or Mapping field, we got 500 error when we list the identity providers > >To test: >1. Apply this patch. >2. Add a new identity provider > 2.1. fill the form > 2.2. click on «Add default Oauth configuration» and on «Add default Oauth mapping» > 2.3. put some special characters in Configuration and Mapping field >3. Save the form >=> Confirm the identity providers list is shown correctly > >Also prove t/db_dependent/api/v1/provider.t. > >Signed-off-by: David Nind <david@davidnind.com> >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > Koha/Auth/Identity/Provider.pm | 4 +- > t/db_dependent/api/v1/provider.t | 66 ++++++++++++++++++++++++++++++++ > 2 files changed, 68 insertions(+), 2 deletions(-) > create mode 100755 t/db_dependent/api/v1/provider.t > >diff --git a/Koha/Auth/Identity/Provider.pm b/Koha/Auth/Identity/Provider.pm >index e9dfc2fddbb..d617b2449a2 100644 >--- a/Koha/Auth/Identity/Provider.pm >+++ b/Koha/Auth/Identity/Provider.pm >@@ -62,7 +62,7 @@ sub get_config { > my ($self) = @_; > > return try { >- return decode_json( $self->config ); >+ return decode_json( Encode::encode_utf8( $self->config ) ); > } > catch { > Koha::Exceptions::Object::BadValue->throw("Error reading JSON data: $_"); >@@ -127,7 +127,7 @@ sub get_mapping { > my ($self) = @_; > > return try { >- return decode_json( $self->mapping ); >+ return decode_json( Encode::encode_utf8( $self->mapping ) ); > } > catch { > Koha::Exceptions::Object::BadValue->throw("Error reading JSON data: $_"); >diff --git a/t/db_dependent/api/v1/provider.t b/t/db_dependent/api/v1/provider.t >new file mode 100755 >index 00000000000..d505fc99d94 >--- /dev/null >+++ b/t/db_dependent/api/v1/provider.t >@@ -0,0 +1,66 @@ >+#!/usr/bin/env perl >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Test::More tests => 1; >+use Test::Mojo; >+use t::lib::TestBuilder; >+use t::lib::Mocks; >+ >+use JSON qw(encode_json); >+ >+use C4::Budgets; >+ >+use Koha::Database; >+ >+my $schema = Koha::Database->new->schema; >+my $builder = t::lib::TestBuilder->new(); >+ >+t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); >+ >+my $t = Test::Mojo->new('Koha::REST::V1'); >+ >+subtest 'list() tests' => sub { >+ >+ plan tests => 4; >+ >+ $schema->storage->txn_begin; >+ >+ my $superlibrarian = >+ $builder->build_object( { class => 'Koha::Patrons', value => { flags => 1 } } ); >+ my $password = 'thePassword123'; >+ $superlibrarian->set_password( { password => $password, skip_validation => 1 } ); >+ $superlibrarian->discard_changes; >+ >+ my $userid = $superlibrarian->userid; >+ >+ $t->get_ok("//$userid:$password@/api/v1/auth/identity_providers")->status_is(200); >+ >+ my $provider = $builder->build_object( { class => 'Koha::Auth::Identity::Providers' } ); >+ >+ $provider->set( >+ { >+ config => '{"some":"value","and":"élève"}', >+ mapping => '{"some":"value","and":"tréma"}' >+ } >+ )->store; >+ >+ $t->get_ok("//$userid:$password@/api/v1/auth/identity_providers")->status_is(200); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.39.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 37157
:
167974
|
168009
| 168176