ports/mail/p5-Mail-SpamAssassin/files/patch-ImageInfo.pm
Beech Rintoul 5dcb72b777 - Update to 3.2.3
- Add reinplace_cmd to respect CC
- From maintainer:
Several security updates from 3.2.1 to 3.2.2, but 3.2.2 broke spamd.
This fixes the spamd problem in 3.2.2 as well.
Build depends for DNS bumped to .60 due to DOS condition,
crypt to 0.24 due to segv in spamd with malformed DomainKey message.
DomainKey plugin turned BACK OFF in default installs (not needed now that DKIM does work)

PR:		ports/115369
Submitted by:	Michael Scheidell <scheidell@secnap.net>`
Approved by:	sat (mentor)
2007-08-13 22:33:32 +00:00

56 lines
1.7 KiB
Perl

--- lib/Mail/SpamAssassin/Plugin/ImageInfo.pm.orig 2007-08-08 05:19:14.000000000 -0800
+++ lib/Mail/SpamAssassin/Plugin/ImageInfo.pm 2007-08-11 12:20:22.000000000 -0800
@@ -49,6 +49,11 @@
# body LARGE_IMAGE_AREA eval:pixel_coverage('all',150000)
# body SMALL_GIF_AREA eval:pixel_coverage('gif',1,40000)
#
+# image_name_regex() examples
+#
+# body CG_DOUBLEDOT_GIF eval:image_name_regex('/^\w{2,9}\.\.gif$/i') # catches double dot gifs abcd..gif
+#
+#
# See the ruleset for ways to meta image_count()
# and pixel_coverage() together.
#
@@ -80,6 +85,7 @@
$self->register_eval_rule ("image_size_exact");
$self->register_eval_rule ("image_size_range");
$self->register_eval_rule ("image_named");
+ $self->register_eval_rule ("image_name_regex");
$self->register_eval_rule ("image_to_text_ratio");
return $self;
@@ -275,6 +281,33 @@
}
# -----------------------------------------
+sub image_name_regex {
+ my ($self,$pms,$body,$re) = @_;
+ return unless (defined $re);
+
+ # make sure we have image data read in.
+ if (!exists $pms->{'imageinfo'}) {
+ $self->_get_images($pms);
+ }
+
+ return 0 unless (exists $pms->{'imageinfo'}->{"names_all"});
+
+ my $hit = 0;
+ foreach my $name (keys %{$pms->{'imageinfo'}->{"names_all"}}) {
+ dbg("imageinfo: checking image named $name against regex $re");
+ my $eval = 'if (q{'.$name.'} =~ ' . $re . ') { $hit = 1; } ';
+ eval $eval;
+ dbg("imageinfo: error in regex $re - $@") if $@;
+ if ($hit) {
+ dbg("imageinfo: image_name_regex hit on $name");
+ return 1;
+ }
+ }
+ return 0;
+
+ }
+
+# -----------------------------------------
sub image_to_text_ratio {
my ($self,$pms,$body,$type,$min,$max) = @_;