Fix passing regex characters to the highlighter, which makes it break. Fixes bug #11311.

This commit is contained in:
Colin Kuskie 2009-12-21 11:38:52 -08:00
parent 4316cd218f
commit 12e160bf8c
3 changed files with 49 additions and 8 deletions

View file

@ -2,6 +2,7 @@
- fixed #11235: wiki search
- fixed #10679: i18n TaxDriver_EU::accept when vies unavailable help (Martin Kamerbeek / Oqapi)
- fixed #11313: bullet list template for navigation
- fixed #11311: Search object and modifiers
7.8.8
- fixed #11289: Gallery with pending version tag causes search engine indexer to puke.

View file

@ -195,7 +195,7 @@ sub view {
$search->search(\%rules);
#Instantiate the highlighter
my @words = split(/\s+/,$keywords);
my @words = grep { $_ ne '' } map { tr/+?*//d; $_; } split(/\s+/,$keywords);
my @wildcards = map { "%" } @words;
my $hl = HTML::Highlight->new(
words => \@words,

View file

@ -16,8 +16,9 @@ use lib "$FindBin::Bin/../../lib";
use WebGUI::Test;
use WebGUI::Session;
use Test::More tests => 6; # increment this value for each test you create
use Test::More tests => 9; # increment this value for each test you create
use WebGUI::Asset::Wobject::Search;
use Data::Dumper;
my $session = WebGUI::Test->session;
@ -26,6 +27,7 @@ my $node = WebGUI::Asset->getImportNode($session);
my $versionTag = WebGUI::VersionTag->getWorking($session);
$versionTag->set({name=>"Search Test"});
addToCleanup($versionTag);
my $search = $node->addChild({className=>'WebGUI::Asset::Wobject::Search'});
# Test for a sane object type
@ -43,15 +45,53 @@ foreach my $newSetting (keys %{$newSearchSettings}) {
is ($search->get($newSetting), $newSearchSettings->{$newSetting}, "updated $newSetting is ".$newSearchSettings->{$newSetting});
}
#1234567890123456789012#
my $templateId = '_FAUX_SEARCH_TEMPLATE_';
my $templateMock = Test::MockObject->new({});
$templateMock->set_isa('WebGUI::Asset::Template');
$templateMock->set_always('getId', $templateId);
$templateMock->set_true('prepare');
my $templateVars;
$templateMock->mock('process', sub { $templateVars = $_[1]; } );
$search->update({
searchRoot => WebGUI::Asset->getDefault($session)->getId,
classLimiter => '',
templateId => $templateId,
});
{
$session->request->setup_body({
doit => 1,
keywords => 'building + applications',
});
WebGUI::Test->mockAssetId($templateId, $templateMock);
$search->prepareView;
eval { $search->view; };
ok(! $@, 'view did now error out on standalone regexp wildcard')
or diag $@;
$session->request->setup_body({
keywords => 'building +applications',
});
eval { $search->view; };
ok(! $@, 'view did now error out on prefix regexp wildcard')
or diag $@;
$session->request->setup_body({
keywords => 'building applications*',
});
eval { $search->view; };
ok(! $@, 'view did now error out on prefix regexp wildcard')
or diag $@;
WebGUI::Test->unmockAssetId($templateId);
}
$session->request->setup_body({});
TODO: {
local $TODO = "Tests to make later";
ok(0, 'Test prepareView method');
ok(0, 'Test view method');
}
END {
# Clean up after thy self
$versionTag->rollback();
}