From 50431a49849089fd1960accc26b934f29763cd99 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 10 Jul 2017 11:56:46 -0300 Subject: [PATCH] Bug 18854: Protect few other occurrences of offset Signed-off-by: Marcel de Rooy Signed-off-by: Jonathan Druart (cherry picked from commit 9f47bd88252e201f9f06fd734dae154d9bc41543) Signed-off-by: Fridolin Somers --- C4/AuthoritiesMarc.pm | 2 +- Koha/SearchEngine/Elasticsearch/Search.pm | 3 ++- admin/auth_subfields_structure.pl | 3 ++- admin/auth_tag_structure.pl | 3 ++- admin/marc_subfields_structure.pl | 3 ++- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index 87620b45cf..9f1f284353 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -240,7 +240,7 @@ sub SearchAuthorities { $query="\@or $orderstring $query" if $orderstring; } - $offset=0 unless $offset; + $offset = 0 if not defined $offset or $offset < 0; my $counter = $offset; $length=10 unless $length; my @oAuth; diff --git a/Koha/SearchEngine/Elasticsearch/Search.pm b/Koha/SearchEngine/Elasticsearch/Search.pm index 9f0e2a5991..cec1cb7fb6 100644 --- a/Koha/SearchEngine/Elasticsearch/Search.pm +++ b/Koha/SearchEngine/Elasticsearch/Search.pm @@ -327,7 +327,8 @@ sub simple_search_compat { return ('No query entered', undef, undef) unless $query; my %options; - $options{offset} = $offset // 0; + $offset = 0 if not defined $offset or $offset < 0; + $options{offset} = $offset; $max_results //= 100; unless (ref $query) { diff --git a/admin/auth_subfields_structure.pl b/admin/auth_subfields_structure.pl index 0ba7677a98..37249e6826 100755 --- a/admin/auth_subfields_structure.pl +++ b/admin/auth_subfields_structure.pl @@ -52,7 +52,8 @@ my $input = new CGI; my $tagfield = $input->param('tagfield'); my $tagsubfield = $input->param('tagsubfield'); my $authtypecode = $input->param('authtypecode'); -my $offset = $input->param('offset') || 0; +my $offset = $input->param('offset'); +$offset = 0 if not defined $offset or $offset < 0; my $op = $input->param('op') || ''; my $script_name = "/cgi-bin/koha/admin/auth_subfields_structure.pl"; diff --git a/admin/auth_tag_structure.pl b/admin/auth_tag_structure.pl index 4a3a67a1bf..ddf163acbc 100755 --- a/admin/auth_tag_structure.pl +++ b/admin/auth_tag_structure.pl @@ -35,7 +35,8 @@ my $authtypecode = $input->param('authtypecode') || ''; # set my $existingauthtypecode = $input->param('existingauthtypecode') || ''; # set when we have to create a new framework (in authtype) by copying an old one (in existingauthtype) my $searchfield = $input->param('searchfield') || 0; -my $offset = $input->param('offset') || 0; +my $offset = $input->param('offset'); +$offset = 0 if not defined $offset or $offset < 0; my $op = $input->param('op') || ''; $searchfield =~ s/\,//g; diff --git a/admin/marc_subfields_structure.pl b/admin/marc_subfields_structure.pl index 24c8005800..077a58b40e 100755 --- a/admin/marc_subfields_structure.pl +++ b/admin/marc_subfields_structure.pl @@ -65,7 +65,8 @@ my $tagfield = $input->param('tagfield'); my $tagsubfield = $input->param('tagsubfield'); my $frameworkcode = $input->param('frameworkcode'); my $pkfield = "tagfield"; -my $offset = $input->param('offset') || 0; +my $offset = $input->param('offset'); +$offset = 0 if not defined $offset or $offset < 0; my $script_name = "/cgi-bin/koha/admin/marc_subfields_structure.pl"; my ( $template, $borrowernumber, $cookie ) = get_template_and_user( -- 2.39.5