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:
Colin Kuskie 2009-08-11 00:11:10 +00:00
parent 6adfc6ccee
commit 9182ce5288
3 changed files with 112 additions and 71 deletions

View file

@ -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;
}
#-------------------------------------------------------------------