From 862f32971075226dcf9ae19ed7cf558a246300ba Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 12 Jun 2014 09:31:35 +0200 Subject: [PATCH] Bug 12368: Die if the --table value is not allowed. If the table given in parameter is not in the white list, the script should die rathen than correct to a default value. Signed-off-by: Chris Cormack --- misc/migration_tools/rebuild_zebra.pl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/misc/migration_tools/rebuild_zebra.pl b/misc/migration_tools/rebuild_zebra.pl index 67b73c7..dd97170 100755 --- a/misc/migration_tools/rebuild_zebra.pl +++ b/misc/migration_tools/rebuild_zebra.pl @@ -136,6 +136,13 @@ if (not $biblios and not $authorities) { die $msg; } +our @tables_allowed_for_select = ( 'biblioitems', 'items', 'biblio' ); +unless ( grep { /^$table$/ } @tables_allowed_for_select ) { + die "Cannot specify -t|--table with value '$table'. Only " + . ( join ', ', @tables_allowed_for_select ) + . " are allowed."; +} + # -v is for verbose, which seems backwards here because of how logging is set # on the CLI of zebraidx. It works this way. The default is to not log much @@ -445,8 +452,7 @@ sub select_all_authorities { sub select_all_biblios { $table = 'biblioitems' - if $table ne 'items' - and $table ne 'biblio'; + if grep { /^$table$/ } @tables_allowed_for_select; my $strsth = qq{ SELECT biblionumber FROM $table }; $strsth.=qq{ WHERE $where } if ($where); $strsth.=qq{ LIMIT $length } if ($length && !$offset); -- 2.1.0