From bf11cd06c556322fe0ed52c3cbf0352ff0bdcc5f 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 Signed-off-by: Martin Renvoize (cherry picked from commit 42a26a758079830758a51845b4526e681b75d434) Signed-off-by: Fridolin Somers --- 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.39.5