astrotrain 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- data/astrotrain.gemspec +3 -2
- data/lib/astrotrain.rb +1 -1
- data/lib/astrotrain/message.rb +4 -1
- data/test/fixtures/utf8.txt +35 -0
- data/test/message_test.rb +18 -0
- metadata +20 -16
data/astrotrain.gemspec
CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
|
|
13
13
|
## If your rubyforge_project name is different, then edit it and comment out
|
14
14
|
## the sub! line in the Rakefile
|
15
15
|
s.name = 'astrotrain'
|
16
|
-
s.version = '0.6.
|
17
|
-
s.date = '2012-04-
|
16
|
+
s.version = '0.6.3'
|
17
|
+
s.date = '2012-04-25'
|
18
18
|
s.rubyforge_project = 'astrotrain'
|
19
19
|
|
20
20
|
## Make sure your summary is short. The description may be as long
|
@@ -81,6 +81,7 @@ Gem::Specification.new do |s|
|
|
81
81
|
test/fixtures/reply.txt
|
82
82
|
test/fixtures/undisclosed.txt
|
83
83
|
test/fixtures/utf-8.txt
|
84
|
+
test/fixtures/utf8.txt
|
84
85
|
test/message_test.rb
|
85
86
|
test/test_helper.rb
|
86
87
|
test/transport_test.rb
|
data/lib/astrotrain.rb
CHANGED
data/lib/astrotrain/message.rb
CHANGED
@@ -307,7 +307,10 @@ module Astrotrain
|
|
307
307
|
# Returns converted String.
|
308
308
|
def convert_to_utf8(s)
|
309
309
|
# If this string is already valid UTF-8 just hand it back
|
310
|
-
|
310
|
+
if s.as_utf8.valid?
|
311
|
+
s.force_encoding("UTF-8") if s.respond_to?(:force_encoding)
|
312
|
+
return s
|
313
|
+
end
|
311
314
|
|
312
315
|
# First lets try to detect the encoding if the message didn't specify
|
313
316
|
if !@mail.charset && detection = CharlockHolmes::EncodingDetector.detect(s)
|
@@ -0,0 +1,35 @@
|
|
1
|
+
Return-Path: <user@astrotrain.com>
|
2
|
+
X-Original-To: reply@astrotrain.com
|
3
|
+
Date: Mon, 16 Apr 2012 15:12:43 -0700
|
4
|
+
From: User <user@astrotrain.com>
|
5
|
+
To: Processor <processor@astrotrain.com>
|
6
|
+
Message-ID: <2B2BC5BB5BCB4F1BB779FEDC693EFDC9@github.com>
|
7
|
+
Subject: Fix this thing
|
8
|
+
MIME-Version: 1.0
|
9
|
+
Content-Type: multipart/alternative; boundary="4f8c995b_6eb5bd4_11cdf"
|
10
|
+
|
11
|
+
--4f8c995b_6eb5bd4_11cdf
|
12
|
+
Content-Type: text/plain; charset="utf-8"
|
13
|
+
Content-Transfer-Encoding: quoted-printable
|
14
|
+
Content-Disposition: inline
|
15
|
+
|
16
|
+
:+1:=5E1 trillion
|
17
|
+
|
18
|
+
> =20
|
19
|
+
> =E2=80=94
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
--4f8c995b_6eb5bd4_11cdf
|
24
|
+
Content-Type: text/html; charset="utf-8"
|
25
|
+
Content-Transfer-Encoding: quoted-printable
|
26
|
+
Content-Disposition: inline
|
27
|
+
|
28
|
+
|
29
|
+
<div style=3D=22font-family: Helvetica; font-size: 13px; =
|
30
|
+
=22>:+1:=5E1 trillion<br></div>
|
31
|
+
<p style=3D=22font-size:small;-webkit-text-size-adjust:none;color:=23666;=
|
32
|
+
=22>=E2=80=94<br>
|
33
|
+
|
34
|
+
--4f8c995b_6eb5bd4_11cdf--
|
35
|
+
|
data/test/message_test.rb
CHANGED
@@ -52,6 +52,7 @@ class MessageParsingTest < Test::Unit::TestCase
|
|
52
52
|
"Dear Sirs, \r\nWe are given to understand that you are Manufacturer of plstic Bottles\r\nAdd\357\274\232 blah China"
|
53
53
|
end
|
54
54
|
assert_equal s, msg.body
|
55
|
+
assert_mail_utf8 msg
|
55
56
|
end
|
56
57
|
|
57
58
|
test "gb2312 encoded body with invalid charset in mime version header" do
|
@@ -60,6 +61,7 @@ class MessageParsingTest < Test::Unit::TestCase
|
|
60
61
|
# "Dear Sirs, \r\nWe are given to understand that you are Manufacturer of plstic Bottles\r\nAdd: blah China"
|
61
62
|
s = "Dear Sirs, \r\nWe are given to understand that you are Manufacturer of plstic Bottles\r\nAdd?? blah China"
|
62
63
|
assert_equal s, msg.body
|
64
|
+
assert_mail_utf8 msg
|
63
65
|
end
|
64
66
|
|
65
67
|
test "utf-8 encoded headers" do
|
@@ -183,4 +185,20 @@ class MessageParsingTest < Test::Unit::TestCase
|
|
183
185
|
msg = Astrotrain::Message.read(path)
|
184
186
|
assert_equal path, msg.path
|
185
187
|
end
|
188
|
+
|
189
|
+
test "parses and transcodes email with utf-8" do
|
190
|
+
path = mail(:utf8)
|
191
|
+
msg = Astrotrain::Message.read(path)
|
192
|
+
assert_mail_utf8 msg
|
193
|
+
end
|
194
|
+
|
195
|
+
def assert_mail_utf8(mail)
|
196
|
+
[:html, :body].each do |attr|
|
197
|
+
str = mail.send(attr)
|
198
|
+
assert str.as_utf8.valid?
|
199
|
+
if str.respond_to?(:encoding)
|
200
|
+
assert_equal "UTF-8", str.encoding.name
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
186
204
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: astrotrain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: utf8
|
16
|
-
requirement: &
|
16
|
+
requirement: &70343659221820 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.1.8
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70343659221820
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: mail
|
27
|
-
requirement: &
|
27
|
+
requirement: &70343659220900 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 2.4.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70343659220900
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: i18n
|
38
|
-
requirement: &
|
38
|
+
requirement: &70343659220240 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 0.6.0
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70343659220240
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: faraday
|
49
|
-
requirement: &
|
49
|
+
requirement: &70343659219600 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 0.5.0
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70343659219600
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: addressable
|
60
|
-
requirement: &
|
60
|
+
requirement: &70343659219040 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 2.2.4
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70343659219040
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: charlock_holmes
|
71
|
-
requirement: &
|
71
|
+
requirement: &70343659218520 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: 0.6.8
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70343659218520
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: resque
|
82
|
-
requirement: &
|
82
|
+
requirement: &70343659217960 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70343659217960
|
91
91
|
description: email => http post
|
92
92
|
email: technoweenie@gmail.com
|
93
93
|
executables: []
|
@@ -124,6 +124,7 @@ files:
|
|
124
124
|
- test/fixtures/reply.txt
|
125
125
|
- test/fixtures/undisclosed.txt
|
126
126
|
- test/fixtures/utf-8.txt
|
127
|
+
- test/fixtures/utf8.txt
|
127
128
|
- test/message_test.rb
|
128
129
|
- test/test_helper.rb
|
129
130
|
- test/transport_test.rb
|
@@ -139,6 +140,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
139
140
|
- - ! '>='
|
140
141
|
- !ruby/object:Gem::Version
|
141
142
|
version: '0'
|
143
|
+
segments:
|
144
|
+
- 0
|
145
|
+
hash: 1829060415533477535
|
142
146
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
147
|
none: false
|
144
148
|
requirements:
|