Anchor words to replace in processReplacements. Fixes bug #11939.
This commit is contained in:
parent
59e848c6a8
commit
e66092deaa
3 changed files with 15 additions and 11 deletions
|
|
@ -23,6 +23,7 @@
|
|||
- fixed #11933: EMS shows a dollar currency symbol on Badge Listing
|
||||
- fixed #11941: cannot edit default templates in some browsers
|
||||
- fixed #11926: Version Tag: Delete
|
||||
- fixed #11939: WebGUI replacements are not anchored.
|
||||
|
||||
7.10.3
|
||||
- fixed #11903: Unnecessary debug in Thingy
|
||||
|
|
|
|||
|
|
@ -387,20 +387,18 @@ sub processReplacements {
|
|||
my $session = shift;
|
||||
my ($content) = @_;
|
||||
my $replacements = $session->stow->get("replacements");
|
||||
if (defined $replacements) {
|
||||
foreach my $searchFor (keys %{$replacements}) {
|
||||
my $replaceWith = $replacements->{$searchFor};
|
||||
$content =~ s/\Q$searchFor/$replaceWith/gs;
|
||||
}
|
||||
} else {
|
||||
if (! defined $replacements) {
|
||||
my $sth = $session->dbSlave->read("select searchFor,replaceWith from replacements");
|
||||
while (my ($searchFor,$replaceWith) = $sth->array) {
|
||||
while (my ($searchFor,$replaceWith) = $sth->array) {
|
||||
$replacements->{$searchFor} = $replaceWith;
|
||||
$content =~ s/\Q$searchFor/$replaceWith/gs;
|
||||
}
|
||||
$sth->finish;
|
||||
$session->stow->set("replacements",$replacements);
|
||||
}
|
||||
$sth->finish;
|
||||
$session->stow->set("replacements",$replacements);
|
||||
}
|
||||
foreach my $searchFor (keys %{$replacements}) {
|
||||
my $replaceWith = $replacements->{$searchFor};
|
||||
$content =~ s/\b\Q$searchFor\E\b/$replaceWith/gs;
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
|
||||
|
|
|
|||
5
t/HTML.t
5
t/HTML.t
|
|
@ -129,6 +129,7 @@ my @htmlTextSets = (
|
|||
my $numTests = scalar @filterSets
|
||||
+ scalar @macroParamSets
|
||||
+ scalar @htmlTextSets
|
||||
+ 3
|
||||
;
|
||||
|
||||
plan tests => $numTests;
|
||||
|
|
@ -147,3 +148,7 @@ foreach my $testSet (@htmlTextSets) {
|
|||
my $text = WebGUI::HTML::html2text($testSet->{inputText});
|
||||
is($text, $testSet->{output}, $testSet->{comment});
|
||||
}
|
||||
|
||||
is(WebGUI::HTML::processReplacements($session, 'grass'), 'grass', 'processReplacements: grass is not replaced');
|
||||
is(WebGUI::HTML::processReplacements($session, 'shitake'), 'shitake', '... shitake is not replaced');
|
||||
is(WebGUI::HTML::processReplacements($session, 'This is shit.'), 'This is crap.', '... shit is replaced');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue