diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index ce67ebe41..7ffdeaa0e 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -21,6 +21,7 @@ http://www.plainblack.com/bugs/tracker/asset-tree-cut-and-paste-not-handled-by-search - fix: Fixed a bug where calendars would generate corrupt iCal feed urls (Martin Kamerbeek / Oqapi) + - fix: Make search indexing work on Windows and made indexing safer overall. - fix: Too many directories in RSS cache (Martin Kamerbeek / Oqapi) http://www.plainblack.com/bugs/tracker/too-many-directories-in-rss-cache - fix: Help link broken for navigation template (perlDreamer Consulting, LLC) diff --git a/lib/WebGUI/Search/Index.pm b/lib/WebGUI/Search/Index.pm index a2933aa31..661b867a3 100644 --- a/lib/WebGUI/Search/Index.pm +++ b/lib/WebGUI/Search/Index.pm @@ -48,14 +48,21 @@ The path to the filename to index, including the filename. =cut sub addFile { - my $self = shift; - my $path = shift; - $path =~ m/\.(\w+)$/; - my $type = lc($1); - my $filters = $self->session->config->get("searchIndexerPlugins"); - my $filter = $filters->{$type}; - my $content = `$filter $path`; - $self->addKeywords($content) if (!$content =~ m/^\s*$/); + my $self = shift; + my $path = shift; + my $filters = $self->session->config->get("searchIndexerPlugins"); + my $content; + if ($path =~ m/\.(\w+)$/) { + my $type = lc($1); + if ($filters->{$type}) { + open my $fh, "$filters->{$type} $path |" or return; # open pipe to filter + $content = do { local $/; <$fh> }; # slurp file + close $fh; + } + } + return $self->addKeywords($content) + if $content =~ m/\S/; # only index if we fine non-whitespace + return; }