Lines 1-98
Link Here
|
1 |
--- ImageInfo.pm.orig Tue May 1 09:54:09 2007 |
1 |
--- ImageInfo.pm.orig Tue May 1 09:54:09 2007 |
2 |
+++ lib/Mail/SpamAssassin/Plugin/ImageInfo.pm Thu May 3 16:08:29 2007 |
2 |
+++ lib/Mail/SpamAssassin/Plugin/ImageInfo.pm Thu May 3 16:08:29 2007 |
3 |
@@ -1,10 +1,9 @@ |
3 |
@@ -49,6 +49,10 @@ |
4 |
# <@LICENSE> |
4 |
# body LARGE_IMAGE_AREA eval:pixel_coverage('all',150000) |
5 |
-# Licensed to the Apache Software Foundation (ASF) under one or more |
5 |
# body SMALL_GIF_AREA eval:pixel_coverage('gif',1,40000) |
6 |
-# contributor license agreements. See the NOTICE file distributed with |
|
|
7 |
-# this work for additional information regarding copyright ownership. |
8 |
-# The ASF licenses this file to you under the Apache License, Version 2.0 |
9 |
-# (the "License"); you may not use this file except in compliance with |
10 |
-# the License. You may obtain a copy of the License at: |
11 |
+# Copyright 2004 Apache Software Foundation |
12 |
+# |
13 |
+# Licensed under the Apache License, Version 2.0 (the "License"); |
14 |
+# you may not use this file except in compliance with the License. |
15 |
+# You may obtain a copy of the License at |
16 |
# |
17 |
# http://www.apache.org/licenses/LICENSE-2.0 |
18 |
# |
19 |
@@ -16,6 +15,36 @@ |
20 |
# </@LICENSE> |
21 |
# |
22 |
# ------------------------------------------------------- |
23 |
+# ImageInfo Plugin for SpamAssassin |
24 |
+# Version: 0.7 |
25 |
+# Current Home: http://www.rulesemporium.com/plugins.htm#imageinfo |
26 |
+# Created: 2006-08-02 |
27 |
+# Modified: 2007-01-17 |
28 |
+# By: Dallas Engelken <dallase@uribl.com> |
29 |
+# |
30 |
+# Changes: |
31 |
+# 0.7 - added image_name_regex to allow pattern matching on the image name |
32 |
+# - added support for image/pjpeg content types (progressive jpeg) |
33 |
+# - updated imageinfo.cf with a few sample rules for using image_name_regex() |
34 |
+# 0.6 - fixed dems_ bug in image_size_range_ |
35 |
+# 0.5 - added image_named and image_to_text_ratio |
36 |
+# 0.4 - added image_size_exact and image_size_range |
37 |
+# 0.3 - added jpeg support |
38 |
+# 0.2 - optimized by theo |
39 |
+# 0.1 - added gif/png support |
40 |
+# |
41 |
+# Files: |
42 |
+# ImageInfo.pm (plugin) - http://www.rulesemporium.com/plugins/ImageInfo.pm |
43 |
+# imageinfo.cf (ruleset) - http://www.rulesemporium.com/plugins/imageinfo.cf |
44 |
+# |
45 |
+# Install: |
46 |
+# 1) place ruleset in your local config dir |
47 |
+# 2) place plugin in your plugins dir |
48 |
+# 3) add to init.pre (or v310.pre) the following line |
49 |
+# loadplugin Mail::SpamAssassin::Plugin::ImageInfo |
50 |
+# or if not in plugin dir.. |
51 |
+# loadplugin Mail::SpamAssassin::Plugin::ImageInfo /path/to/plugin |
52 |
+# 4) restart spamd (if necessary) |
53 |
# |
54 |
# Usage: |
55 |
# image_count() |
56 |
@@ -27,7 +56,7 @@ |
57 |
# max: optional, if specified, message must not |
58 |
# contain more than this number of images |
59 |
# |
6 |
# |
60 |
-# examples |
|
|
61 |
+# image_count() examples |
62 |
# |
63 |
# body ONE_IMAGE eval:image_count('all',1,1) |
64 |
# body ONE_OR_MORE_IMAGES eval:image_count('all',1) |
65 |
@@ -44,13 +73,24 @@ |
66 |
# max: optional, if specified, message must not |
67 |
# contain more than this much pixel area |
68 |
# |
69 |
-# examples |
70 |
+# pixel_coverage() examples |
71 |
+# |
72 |
+# body LARGE_IMAGE_AREA eval:pixel_coverage('all',150000) # catches any images that are 150k pixel/sq or higher |
73 |
+# body SMALL_GIF_AREA eval:pixel_coverage('gif',1,40000) # catches only gifs that 1 to 40k pixel/sql |
74 |
+# |
75 |
+# image_name_regex() |
76 |
+# |
77 |
+# body RULENAME eval:image_name_regex(<regex>) |
78 |
+# regex: full quoted regexp, see examples below |
79 |
+# |
80 |
+# image_name_regex() examples |
7 |
+# image_name_regex() examples |
81 |
+# |
8 |
+# |
82 |
+# body CG_DOUBLEDOT_GIF eval:image_name_regex('/^\w{2,9}\.\.gif$/i') # catches double dot gifs abcd..gif |
9 |
+# body CG_DOUBLEDOT_GIF eval:image_name_regex('/^\w{2,9}\.\.gif$/i') # catches double dot gifs abcd..gif |
|
|
10 |
+# |
11 |
# See the ruleset for ways to meta image_count() |
12 |
# and pixel_coverage() together. |
83 |
# |
13 |
# |
84 |
-# body LARGE_IMAGE_AREA eval:pixel_coverage('all',150000) |
14 |
@@ -80,6 +84,7 @@ |
85 |
-# body SMALL_GIF_AREA eval:pixel_coverage('gif',1,40000) |
|
|
86 |
+# See the ruleset for more examples that arent documented here. |
87 |
# |
88 |
-# See the ruleset for ways to meta image_count() |
89 |
-# and pixel_coverage() together. |
90 |
+# New functions added in v0.5+ need some documentation here. Or just |
91 |
+# see .cf for sample rules. |
92 |
# |
93 |
# ------------------------------------------------------- |
94 |
|
95 |
@@ -80,6 +120,7 @@ |
96 |
$self->register_eval_rule ("image_size_exact"); |
15 |
$self->register_eval_rule ("image_size_exact"); |
97 |
$self->register_eval_rule ("image_size_range"); |
16 |
$self->register_eval_rule ("image_size_range"); |
98 |
$self->register_eval_rule ("image_named"); |
17 |
$self->register_eval_rule ("image_named"); |
Lines 100-109
Link Here
|
100 |
$self->register_eval_rule ("image_to_text_ratio"); |
19 |
$self->register_eval_rule ("image_to_text_ratio"); |
101 |
|
20 |
|
102 |
return $self; |
21 |
return $self; |
103 |
@@ -244,6 +285,34 @@ |
22 |
@@ -272,6 +277,33 @@ |
104 |
|
|
|
105 |
# ----------------------------------------- |
106 |
|
23 |
|
|
|
24 |
# dbg("imageinfo: pc_$type: $min, ".($max ? $max:'').", $type, ".$pms->{'imageinfo'}->{"pc_$type"}); |
25 |
return result_check($min, $max, $pms->{'imageinfo'}->{"pc_$type"}); |
26 |
+} |
27 |
+ |
28 |
+# ----------------------------------------- |
107 |
+sub image_name_regex { |
29 |
+sub image_name_regex { |
108 |
+ my ($self,$pms,$body,$re) = @_; |
30 |
+ my ($self,$pms,$body,$re) = @_; |
109 |
+ return unless (defined $re); |
31 |
+ return unless (defined $re); |
Lines 128-147
Link Here
|
128 |
+ } |
50 |
+ } |
129 |
+ return 0; |
51 |
+ return 0; |
130 |
+ |
52 |
+ |
131 |
+} |
|
|
132 |
+ |
133 |
+# ----------------------------------------- |
134 |
+ |
135 |
sub image_count { |
136 |
my ($self,$pms,$body,$type,$min,$max) = @_; |
137 |
|
138 |
@@ -323,7 +392,8 @@ |
139 |
$self->_get_images($pms); |
140 |
} |
53 |
} |
141 |
|
54 |
|
142 |
- return unless (exists $pms->{'imageinfo'}->{"dems_$type"}); |
55 |
# ----------------------------------------- |
143 |
+ my $name = 'dems_'.$type; |
|
|
144 |
+ return unless (exists $pms->{'imageinfo'}->{$name}); |
145 |
|
56 |
|
146 |
foreach my $dem ( keys %{$pms->{'imageinfo'}->{"dems_$type"}}) { |
|
|
147 |
my ($h,$w) = split(/x/,$dem); |