Bugzilla – Attachment 56487 Details for
Bug 17445
REST API: Generic handling of malformed query parameters
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
BUG 17455: Add 'malformed query' error response
BUG-17455-Add-malformed-query-error-response.patch (text/plain), 1.37 KB, created by
Martin Renvoize
on 2016-10-14 08:59:35 UTC
(
hide
)
Description:
BUG 17455: Add 'malformed query' error response
Filename:
MIME Type:
Creator:
Martin Renvoize
Created:
2016-10-14 08:59:35 UTC
Size:
1.37 KB
patch
obsolete
>From aa796a8c2b3f58174c6603ef5581ab93b189f1bb Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 14 Oct 2016 08:57:30 +0000 >Subject: [PATCH] BUG 17455: Add 'malformed query' error response > >This patch adds to the x-mojo-around action code to give a meaningful >error given a bad query parameter in the query string for a request. > >https://bugs.koha-community.org/show_bug.cgi?id=17445 >--- > Koha/REST/V1.pm | 9 +++++++++ > 1 file changed, 9 insertions(+) > >diff --git a/Koha/REST/V1.pm b/Koha/REST/V1.pm >index d62ee23..a6dd58e 100644 >--- a/Koha/REST/V1.pm >+++ b/Koha/REST/V1.pm >@@ -91,6 +91,15 @@ sub authenticate_api_request { > ) if $cookie and $action_spec->{'x-koha-authorization'}; > } > >+ # Check for malformed query parameters >+ my @errors; >+ my %valid_parameters = map { $_->{name} => 1 if $_->{in} eq 'query'; } @{$action_spec->{parameters}}; >+ my $existing_params = $c->req->query_params->to_hash; >+ for my $param ( keys %{$existing_params} ) { >+ push @errors, { path => "/query/".$param, message => 'Malformed query string' } unless exists $valid_parameters{$param}; >+ } >+ return $c->render_swagger(@errors,{},400) if @errors; >+ > return $next->($c) unless $action_spec->{'x-koha-authorization'}; > unless ($user) { > return $c->render_swagger({ error => "Authentication required." },{},401); >-- >2.1.4
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 17445
:
56487
|
56488
|
56500
|
56546
|
56547
|
56634
|
56635
|
56636
|
56659
|
56660
|
56661