entp-astrotrain 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/astrotrain.gemspec +2 -2
- data/lib/astrotrain/message.rb +19 -2
- data/lib/astrotrain/tmail.rb +10 -0
- data/test/message_test.rb +16 -0
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
data/astrotrain.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{astrotrain}
|
5
|
-
s.version = "0.2.
|
5
|
+
s.version = "0.2.1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["technoweenie"]
|
9
|
-
s.date = %q{2009-09-
|
9
|
+
s.date = %q{2009-09-23}
|
10
10
|
s.email = %q{technoweenie@gmail.com}
|
11
11
|
s.extra_rdoc_files = [
|
12
12
|
"LICENSE",
|
data/lib/astrotrain/message.rb
CHANGED
@@ -190,12 +190,29 @@ module Astrotrain
|
|
190
190
|
@mail.port.to_s
|
191
191
|
end
|
192
192
|
|
193
|
+
def header(key)
|
194
|
+
@headers ||= {}
|
195
|
+
if !@headers.key?(key)
|
196
|
+
@headers[key] = if self.class.skipped_headers.include?(key)
|
197
|
+
nil
|
198
|
+
else
|
199
|
+
header = @mail.header[key]
|
200
|
+
begin
|
201
|
+
header.to_s
|
202
|
+
rescue
|
203
|
+
header.raw_body
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
@headers[key]
|
208
|
+
end
|
209
|
+
|
193
210
|
def headers
|
194
211
|
@headers ||= begin
|
195
212
|
h = {}
|
196
213
|
@mail.header.each do |key, value|
|
197
|
-
|
198
|
-
h[key] =
|
214
|
+
header_value = header(key)
|
215
|
+
h[key] = header_value if header_value
|
199
216
|
end
|
200
217
|
h
|
201
218
|
end
|
data/lib/astrotrain/tmail.rb
CHANGED
data/test/message_test.rb
CHANGED
@@ -123,6 +123,22 @@ class Astrotrain::MessageTest < Astrotrain::TestCase
|
|
123
123
|
@body = "---------- Forwarded message ----------\nblah blah"
|
124
124
|
end
|
125
125
|
|
126
|
+
describe "basic, with bad content type header" do
|
127
|
+
before :all do
|
128
|
+
@raw = mail(:bad_content_type)
|
129
|
+
@message = Astrotrain::Message.parse(@raw)
|
130
|
+
end
|
131
|
+
|
132
|
+
it "parses body" do
|
133
|
+
expected = "--====boundary====\nContent-Type: text/plain; charset=\"us-ascii\"\n\nThis message is being generated automatically to notify you\nthat PowerMTA has crashed on mtasv.net.\n\nAs the information below is likely to be essential for debugging\nthe problem, please forward this message to <support@port25.com>.\nThank you.\n\n--====boundary====\nContent-Type: text/plain; charset=\"us-ascii\"\n\nYo\n--====boundary====--"
|
134
|
+
assert_equal expected, @message.body
|
135
|
+
end
|
136
|
+
|
137
|
+
it "attempts parsing bad header" do
|
138
|
+
assert_equal "multipart/mixed; boundary=\"====boundary=\"===\"\"", @message.header('content-type')
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
126
142
|
describe "basic, single sender/recipient" do
|
127
143
|
before :all do
|
128
144
|
@raw = mail(:basic)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: entp-astrotrain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- technoweenie
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-09-
|
12
|
+
date: 2009-09-23 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|