summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess <joey@kodama.kitenet.net>2008-06-04 00:25:56 -0400
committerJoey Hess <joey@kodama.kitenet.net>2008-06-04 00:25:56 -0400
commitaefe5dd9cb270bd4fceb7922f0a0b09263d211ee (patch)
treed2126b242125fae6cfa079408daee0a9e1eaf2bc
parentfab1333b6704f5ccd502a5a108c4899aeaf5f675 (diff)
more substr fixes
-rw-r--r--IkiWiki/Plugin/search.pm11
1 files changed, 6 insertions, 5 deletions
diff --git a/IkiWiki/Plugin/search.pm b/IkiWiki/Plugin/search.pm
index e12c9bca4..2de1cf7ac 100644
--- a/IkiWiki/Plugin/search.pm
+++ b/IkiWiki/Plugin/search.pm
@@ -87,20 +87,21 @@ sub filter (@) { #{{{
$scrubber=HTML::Scrubber->new(allow => []);
}
my $toindex=$scrubber->scrub($params{content});
-
+
# Take 512 characters for a sample, then extend it out
# if it stopped in the middle of a word.
my $size=512;
my ($sample)=substr($toindex, 0, $size);
if (length($sample) == $size) {
- my $next=substr($toindex, $size++, 1);
- while (defined $next && $next !~ /\s/) {
+ my $max=length($toindex);
+ my $next;
+ while ($size < $max &&
+ ($next=substr($toindex, $size++, 1)) !~ /\s/) {
$sample.=$next;
- $next=substr($toindex, $size++, 1);
}
}
$sample=~s/\n/ /g;
-
+
# data used by omega
$doc->set_data(
"url=".urlto($params{page}, "")."\n".