Bugzilla – Attachment 163388 Details for
Bug 36351
CSRF Adjustments for Cataloguing editor
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36351: Fix http-client when response is not JSON
Bug-36351-Fix-http-client-when-response-is-not-JSO.patch (text/plain), 2.52 KB, created by
Jonathan Druart
on 2024-03-19 11:05:43 UTC
(
hide
)
Description:
Bug 36351: Fix http-client when response is not JSON
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2024-03-19 11:05:43 UTC
Size:
2.52 KB
patch
obsolete
>From eaec23289c6861b6e3b1c18e474c70617355dbb7 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 19 Mar 2024 12:04:43 +0100 >Subject: [PATCH] Bug 36351: Fix http-client when response is not JSON > >--- > .../intranet-tmpl/lib/koha/cateditor/koha-backend.js | 2 +- > koha-tmpl/intranet-tmpl/prog/js/fetch/http-client.js | 8 ++++++-- > 2 files changed, 7 insertions(+), 3 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/koha-backend.js b/koha-tmpl/intranet-tmpl/lib/koha/cateditor/koha-backend.js >index 2fded33d038..8586206ade0 100644 >--- a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/koha-backend.js >+++ b/koha-tmpl/intranet-tmpl/lib/koha/cateditor/koha-backend.js >@@ -139,7 +139,7 @@ define( [ '/cgi-bin/koha/svc/cataloguing/framework?frameworkcode=&callback=defin > const client = APIClient.cataloguing; > client.catalog_bib.create({ frameworkcode, record }).then( > success => { >- var record = _fromXMLStruct( data ); >+ var record = _fromXMLStruct( success ); > if ( record.marcxml ) { > record.marcxml[0].frameworkcode = frameworkcode; > } >diff --git a/koha-tmpl/intranet-tmpl/prog/js/fetch/http-client.js b/koha-tmpl/intranet-tmpl/prog/js/fetch/http-client.js >index f5340df9467..a379a1f8675 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/fetch/http-client.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/fetch/http-client.js >@@ -38,10 +38,11 @@ class HttpClient { > headers: { ...this._headers, ...headers }, > }) > .then(response => { >+ const is_json = response.headers.get("content-type")?.includes("application/json"); > if (!response.ok) { > return response.text().then(text => { > let message; >- if (text) { >+ if (text && is_json) { > let json = JSON.parse(text); > message = > json.error || >@@ -53,7 +54,10 @@ class HttpClient { > throw new Error(message); > }); > } >- return return_response ? response : response.json(); >+ if ( return_response || !is_json ) { >+ return response; >+ } >+ return response.json(); > }) > .then(result => { > res = result; >-- >2.34.1
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 36351
:
163362
|
163364
|
163387
|
163388
|
163457
|
163458
|
163459
|
163489
|
163490
|
163491
|
163492