gurgitate-mail 1.9.0 → 1.9.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/gurgitate-mail.rb +16 -7
- data/lib/gurgitate/deliver.rb +1 -1
- data/lib/gurgitate/headers.rb +9 -3
- data/lib/gurgitate/mailmessage.rb +4 -2
- data/test/test_headers.rb +8 -3
- metadata +11 -11
data/lib/gurgitate-mail.rb
CHANGED
@@ -126,7 +126,7 @@ module Gurgitate
|
|
126
126
|
@rules = []
|
127
127
|
|
128
128
|
input_text = ""
|
129
|
-
input.
|
129
|
+
input.each_line do |l| input_text << l end
|
130
130
|
super(input_text, recipient, sender)
|
131
131
|
instance_eval(&block) if block_given?
|
132
132
|
end
|
@@ -218,8 +218,12 @@ module Gurgitate
|
|
218
218
|
def filter(program,&block)
|
219
219
|
self.log "Filtering with "+program
|
220
220
|
IO.popen("-","w+") do |filter|
|
221
|
-
|
222
|
-
|
221
|
+
unless filter then
|
222
|
+
begin
|
223
|
+
exec(program)
|
224
|
+
rescue
|
225
|
+
exit! # should not get here anyway
|
226
|
+
end
|
223
227
|
else
|
224
228
|
if fork
|
225
229
|
filter.close_write
|
@@ -227,10 +231,15 @@ module Gurgitate
|
|
227
231
|
g.instance_eval(&block) if block_given?
|
228
232
|
return g
|
229
233
|
else
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
+
begin
|
235
|
+
filter.close_read
|
236
|
+
filter.print to_s
|
237
|
+
filter.close
|
238
|
+
rescue
|
239
|
+
nil
|
240
|
+
ensure
|
241
|
+
exit!
|
242
|
+
end
|
234
243
|
end
|
235
244
|
end
|
236
245
|
end
|
data/lib/gurgitate/deliver.rb
CHANGED
data/lib/gurgitate/headers.rb
CHANGED
@@ -31,6 +31,12 @@ module Gurgitate
|
|
31
31
|
)
|
32
32
|
end
|
33
33
|
|
34
|
+
def to_s
|
35
|
+
map do |member|
|
36
|
+
member.to_s
|
37
|
+
end.join ""
|
38
|
+
end
|
39
|
+
|
34
40
|
end
|
35
41
|
|
36
42
|
# A slightly bigger class for all of a message's headers
|
@@ -63,7 +69,7 @@ module Gurgitate
|
|
63
69
|
end
|
64
70
|
|
65
71
|
def parse_headers
|
66
|
-
@headertext.
|
72
|
+
@headertext.each_line do |h|
|
67
73
|
h.chomp!
|
68
74
|
if(h=~/^\s+/) then
|
69
75
|
@lastheader << h
|
@@ -262,8 +268,8 @@ module Gurgitate
|
|
262
268
|
# the "From " line
|
263
269
|
def to_s
|
264
270
|
if @headers_changed then
|
265
|
-
return @headers.map do |
|
266
|
-
|
271
|
+
return @headers.map do |name,hdr|
|
272
|
+
hdr.map do |hdr_content| hdr_content.to_s end.join("\n")
|
267
273
|
end.join("\n")
|
268
274
|
else
|
269
275
|
return @headertext
|
@@ -58,13 +58,15 @@ module Gurgitate
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def initialize(text=nil, recipient=nil, sender=nil)
|
61
|
+
|
62
|
+
@recipient = recipient
|
63
|
+
@sender = sender
|
64
|
+
|
61
65
|
if text
|
62
66
|
(@headertext,@body)=text.split(/\n\n/,2)
|
63
67
|
@headers=Headers.new(@headertext);
|
64
68
|
Fromregex.match(@headers["From"][0].contents);
|
65
69
|
@from=$+
|
66
|
-
@recipient = recipient
|
67
|
-
@sender = sender
|
68
70
|
else
|
69
71
|
@headers = Headers.new
|
70
72
|
@body = ""
|
data/test/test_headers.rb
CHANGED
@@ -8,9 +8,14 @@ require 'test/unit'
|
|
8
8
|
require 'test/unit/ui/console/testrunner'
|
9
9
|
require 'stringio'
|
10
10
|
|
11
|
+
builddir = File.join(File.dirname(__FILE__),"..")
|
12
|
+
unless $:[0] == builddir
|
13
|
+
$:.unshift builddir
|
14
|
+
end
|
15
|
+
|
11
16
|
class TC_Headers < Test::Unit::TestCase
|
12
17
|
def setup
|
13
|
-
require '
|
18
|
+
require 'gurgitate-mail'
|
14
19
|
end
|
15
20
|
|
16
21
|
def test_single_header
|
@@ -387,7 +392,7 @@ EOF
|
|
387
392
|
"headers contains toline")
|
388
393
|
assert_equal(false,h["From","To"] =~ /nonexistent@example.com/,
|
389
394
|
"headers do not contain nonexistent value")
|
390
|
-
|
395
|
+
assert(!(h["Rabbit"] =~ /nonexistent/),
|
391
396
|
"Asking for a nonexistent header")
|
392
397
|
end
|
393
398
|
|
@@ -422,7 +427,7 @@ EOF
|
|
422
427
|
|
423
428
|
assert_equal(false,h["To"] =~ /\blunar@lunar-linux.org\b/i,
|
424
429
|
"There should be no Lunar Linux mailing list in To line")
|
425
|
-
|
430
|
+
assert(!(h["Cc"] =~ /\blunar@lunar-linux.org\b/i),
|
426
431
|
"There should be no Lunar Linux mailing list in Cc line")
|
427
432
|
end
|
428
433
|
end
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.
|
2
|
+
rubygems_version: 0.9.4
|
3
3
|
specification_version: 1
|
4
4
|
name: gurgitate-mail
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.9.
|
7
|
-
date: 2007-12-
|
6
|
+
version: 1.9.1
|
7
|
+
date: 2007-12-27 00:00:00 +09:00
|
8
8
|
summary: gurgitate-mail is a mail filter (and a mail-delivery agent)
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -30,23 +30,23 @@ authors:
|
|
30
30
|
- Dave Brown
|
31
31
|
files:
|
32
32
|
- lib/gurgitate-mail.rb
|
33
|
-
- lib/gurgitate/deliver.rb
|
34
33
|
- lib/gurgitate/headers.rb
|
35
|
-
- lib/gurgitate/header.rb
|
36
34
|
- lib/gurgitate/mailmessage.rb
|
37
35
|
- lib/gurgitate/deliver/maildir.rb
|
38
36
|
- lib/gurgitate/deliver/mbox.rb
|
39
|
-
-
|
40
|
-
-
|
41
|
-
- test/test_rules.rb
|
42
|
-
- test/test_process.rb
|
37
|
+
- lib/gurgitate/deliver.rb
|
38
|
+
- lib/gurgitate/header.rb
|
43
39
|
- test/test_configuration.rb
|
44
40
|
- test/test_headers.rb
|
41
|
+
- test/test_gurgitate_delivery.rb
|
42
|
+
- test/test_delivery.rb
|
43
|
+
- test/test_process.rb
|
44
|
+
- test/runtests.rb
|
45
45
|
- test/gurgitate-test.rb
|
46
46
|
- test/test_deliver.rb
|
47
|
-
- test/
|
47
|
+
- test/test_rules.rb
|
48
48
|
- test/test_writing.rb
|
49
|
-
- test/
|
49
|
+
- test/test_header.rb
|
50
50
|
test_files:
|
51
51
|
- test/runtests.rb
|
52
52
|
rdoc_options: []
|