summaryrefslogtreecommitdiff
path: root/rt/sbin/rt-fulltext-indexer.in
diff options
context:
space:
mode:
Diffstat (limited to 'rt/sbin/rt-fulltext-indexer.in')
-rw-r--r--rt/sbin/rt-fulltext-indexer.in20
1 files changed, 19 insertions, 1 deletions
diff --git a/rt/sbin/rt-fulltext-indexer.in b/rt/sbin/rt-fulltext-indexer.in
index bd55adb9a..ceffc97b8 100644
--- a/rt/sbin/rt-fulltext-indexer.in
+++ b/rt/sbin/rt-fulltext-indexer.in
@@ -3,7 +3,7 @@
#
# COPYRIGHT:
#
-# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC
+# This software is Copyright (c) 1996-2016 Best Practical Solutions, LLC
# <sales@bestpractical.com>
#
# (Except where explicitly superseded by other copyright notices)
@@ -99,6 +99,8 @@ if ( !flock main::DATA, LOCK_EX | LOCK_NB ) {
}
}
+my $max_size = RT->Config->Get('MaxFulltextAttachmentSize');
+
my $db_type = RT->Config->Get('DatabaseType');
my $fts_config = $ENV{RT_FTS_CONFIG} ? JSON::from_json($ENV{RT_FTS_CONFIG})
: RT->Config->Get('FullTextSearch') || {};
@@ -201,8 +203,16 @@ sub process_bulk_insert {
my ($attachments) = @_;
my @insert;
my $found = 0;
+
while ( my $a = $attachments->Next ) {
debug("Found attachment #". $a->id );
+ if ( $max_size and $a->ContentLength > $max_size ){
+ debug("Attachment #" . $a->id . " is " . $a->ContentLength .
+ " bytes which is larger than configured MaxFulltextAttachmentSize " .
+ " of " . $max_size . ", skipping");
+ next;
+ }
+
my $text = $a->Content // "";
HTML::Entities::decode_entities($text) if $a->ContentType eq "text/html";
push @insert, $text, $a->id;
@@ -304,9 +314,17 @@ sub process_pg_update {
attachment_loop( sub {
my ($attachments) = @_;
my @insert;
+
while ( my $a = $attachments->Next ) {
debug("Found attachment #". $a->id );
+ if ( $max_size and $a->ContentLength > $max_size ){
+ debug("Attachment #" . $a->id . " is " . $a->ContentLength .
+ " bytes which is larger than configured MaxFulltextAttachmentSize " .
+ " of " . $max_size . ", skipping");
+ next;
+ }
+
my $text = $a->Content // "";
HTML::Entities::decode_entities($text) if $a->ContentType eq "text/html";