From a522645e90c3f8c0b3b8087378fe25aaaf1f81ad Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Thu, 13 Jun 2019 19:27:00 +0000 Subject: [PATCH] Bug 17526: Change grep to deal with malformed sortfield Giving sortfield a malformed value when viewing lists results in Internal Server Error. eg. http://localhost:8080/cgi-bin/koha/opac-shelves.pl?op=view&shelfnumber=1&sortfield=title( Note the trailing ( Before Patch: kaboom apply patch restart After Patch: No kaboom Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer --- opac/opac-shelves.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opac/opac-shelves.pl b/opac/opac-shelves.pl index d235292875..cca12f2bb2 100755 --- a/opac/opac-shelves.pl +++ b/opac/opac-shelves.pl @@ -235,7 +235,7 @@ if ( $op eq 'view' ) { if ( $shelf->can_be_viewed( $loggedinuser ) ) { $category = $shelf->category; my $sortfield = $query->param('sortfield') || $shelf->sortfield; # Passed in sorting overrides default sorting - $sortfield = 'title' unless grep {/^$sortfield$/}qw( title author copyrightdate itemcallnumber dateadded ); + $sortfield = 'title' unless grep $_ eq $sortfield, qw( title author copyrightdate itemcallnumber dateadded ); my $direction = $query->param('direction') || 'asc'; $direction = 'asc' if $direction ne 'asc' and $direction ne 'desc'; my ( $page, $rows ); -- 2.11.0