Fix queryIsAllowed to look at the first word in the query, regardless of punctuation or whitespace.
Add tests for queryIsAllowed.
This commit is contained in:
parent
6adfc6ccee
commit
9182ce5288
3 changed files with 112 additions and 71 deletions
|
|
@ -381,14 +381,12 @@ The SQL query which is to be investigated.
|
|||
=cut
|
||||
|
||||
sub queryIsAllowed {
|
||||
my $self = shift;
|
||||
my $self = shift;
|
||||
my $query = shift;
|
||||
|
||||
foreach (split(/\s+/, $self->{_databaseLink}{allowedKeywords})) {
|
||||
return 1 if ($query =~ m/^$_/i);
|
||||
}
|
||||
|
||||
return 0;
|
||||
my ($firstWord) = $query =~ /(\w+)/;
|
||||
$firstWord = lc $firstWord;
|
||||
return isIn($firstWord, split(/\s+/, lc $self->{_databaseLink}{allowedKeywords})) ? 1 : 0;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue