fix extra links added when viewing only wiki page

This commit is contained in:
Graham Knop 2007-09-19 17:10:39 +00:00
parent f4139a2a81
commit 8e36c9ef13
2 changed files with 3 additions and 2 deletions

View file

@ -13,6 +13,7 @@
had been deleted. (Martin Kamerbeek / Oqapi)
- fix: Events don't display on last day of week on week view
- fix: Data Form tab delimited export doesn't obey field order
- fix: Extra <a> tags inserted when viewing only Wiki page
7.4.6
- Prevent Help index from trying to link to non-existant documentation

View file

@ -95,7 +95,6 @@ sub autolinkHtml {
my $skipTitles = $opts{skipTitles} || [];
# TODO: ignore caching for now, but maybe do it later.
my %mapping = $self->session->db->buildHash("SELECT LOWER(d.title), d.url FROM asset AS i INNER JOIN assetData AS d ON i.assetId = d.assetId WHERE i.parentId = ? and className='WebGUI::Asset::WikiPage'", [$self->getId]);
return $html unless %mapping;
foreach my $key (keys %mapping) {
if (grep {lc $_ eq $key} @$skipTitles) {
delete $mapping{$key};
@ -105,9 +104,10 @@ sub autolinkHtml {
$key =~ s{\)}{\\\)}gxms; # escape parens
$mapping{$key} = $self->session->url->gateway($mapping{$key});
}
return $html unless %mapping;
# sort by length so it prefers matching longer titles
my $matchString = join('|', map{quotemeta} sort {length($b) <=> length($a)} keys %mapping);
my $regexp = qr/($matchString)/i;
my $regexp = qr/($matchString)/i;
my @acc = ();
my $in_a = 0;
my $p = HTML::Parser->new;