View | Details | Raw Unified | Return to bug 37018
Collapse All | Expand All

(-)a/Koha/REST/Plugin/Query.pm (-4 lines)
Lines 203-212 Validate operators in the passed query. Link Here
203
                _validate_query( $args->{filtered_params} );
203
                _validate_query( $args->{filtered_params} );
204
            } catch {
204
            } catch {
205
                if ( blessed $_ && $_->isa('Koha::Exceptions::BadParameter') ) {
205
                if ( blessed $_ && $_->isa('Koha::Exceptions::BadParameter') ) {
206
                    $c->render(
207
                        status  => 400,
208
                        json => { error => $_->error }
209
                    );
210
                    Koha::Exceptions::BadParameter->throw( $_->error );
206
                    Koha::Exceptions::BadParameter->throw( $_->error );
211
                }
207
                }
212
            };
208
            };
(-)a/t/Koha/REST/Plugin/Query.t (-3 / +2 lines)
Lines 218-224 get '/dbic_validate_operators' => sub { Link Here
218
    }
218
    }
219
    catch {
219
    catch {
220
        $c->render(
220
        $c->render(
221
			status => 400,
221
			status => 500,
222
            json   => { error => "$_" }
222
            json   => { error => "$_" }
223
        );
223
        );
224
    };
224
    };
Lines 689-695 subtest 'dbic_validate_operators' => sub { Link Here
689
    # Invalid queries
689
    # Invalid queries
690
    $q = [ { "-and" => [ [ { "biblio_id" => { "like(sleep(1/100000))or" => "%a%" } } ] ] } ];
690
    $q = [ { "-and" => [ [ { "biblio_id" => { "like(sleep(1/100000))or" => "%a%" } } ] ] } ];
691
    $t->get_ok( '/dbic_validate_operators' => json => { q => $q } )
691
    $t->get_ok( '/dbic_validate_operators' => json => { q => $q } )
692
		->status_is(400)
692
		->status_is(500)
693
		->json_is( '/error' =>
693
		->json_is( '/error' =>
694
			qq{Exception 'Koha::Exceptions::BadParameter' thrown 'Invalid operator in query: like(sleep(1/100000))or'\n}
694
			qq{Exception 'Koha::Exceptions::BadParameter' thrown 'Invalid operator in query: like(sleep(1/100000))or'\n}
695
		);
695
		);
696
- 

Return to bug 37018