mailparser 0.5.0.beta4 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/mailparser/rfc2047.rb +3 -6
- data/test/test_rfc2047.rb +0 -10
- metadata +15 -15
data/lib/mailparser/rfc2047.rb
CHANGED
@@ -23,8 +23,8 @@ module MailParser::RFC2047
|
|
23
23
|
last_charset = nil
|
24
24
|
words = []
|
25
25
|
mime_word = false
|
26
|
-
str.
|
27
|
-
s, cs, raw
|
26
|
+
str.split(/(\s+)/).each do |s|
|
27
|
+
s, cs, raw = decode_word(s)
|
28
28
|
if charset
|
29
29
|
begin
|
30
30
|
s = charset_converter.call(cs || charset, charset, s)
|
@@ -39,9 +39,7 @@ module MailParser::RFC2047
|
|
39
39
|
elsif s !~ /\A\s*\z/
|
40
40
|
mime_word = false
|
41
41
|
end
|
42
|
-
words.push pre if pre
|
43
42
|
words.push s
|
44
|
-
words.push post if post
|
45
43
|
end
|
46
44
|
begin
|
47
45
|
ret = words.join
|
@@ -54,7 +52,6 @@ module MailParser::RFC2047
|
|
54
52
|
def decode_word(str)
|
55
53
|
charset = nil
|
56
54
|
if str =~ /\=\?([^\(\)\<\>\@\,\;\:\"\/\[\]\?\.\=]+)\?([QB])\?([^\? ]+)\?\=/i
|
57
|
-
pre, post = $`, $'
|
58
55
|
charset, encoding, enc_text = $1.downcase, $2.downcase, $3
|
59
56
|
raw = str
|
60
57
|
str = encoding == "q" ? q_decode(enc_text) : b_decode(enc_text)
|
@@ -66,7 +63,7 @@ module MailParser::RFC2047
|
|
66
63
|
end
|
67
64
|
end
|
68
65
|
end
|
69
|
-
[str, charset, raw
|
66
|
+
[str, charset, raw]
|
70
67
|
end
|
71
68
|
|
72
69
|
def q_decode(str)
|
data/test/test_rfc2047.rb
CHANGED
@@ -144,14 +144,4 @@ class TC_RFC2047 < Test::Unit::TestCase
|
|
144
144
|
assert_equal("hXge", s)
|
145
145
|
end
|
146
146
|
|
147
|
-
def test_decode_with_crlf
|
148
|
-
s = MailParser::RFC2047.decode("abc\r\n def\r\n")
|
149
|
-
assert_equal "abc def", s
|
150
|
-
end
|
151
|
-
|
152
|
-
def test_decode_with_invalid_encoded
|
153
|
-
s = MailParser::RFC2047.decode("abc def=?us-ascii?q?ghi?=jkl mno")
|
154
|
-
assert_equal "abc def ghi jkl mno", s
|
155
|
-
end
|
156
|
-
|
157
147
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mailparser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.0
|
5
|
-
prerelease:
|
4
|
+
version: 0.5.0
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- TOMITA Masahiro
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-09-
|
12
|
+
date: 2012-09-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mmapscanner
|
@@ -37,26 +37,26 @@ files:
|
|
37
37
|
- lib/mailparser.rb
|
38
38
|
- lib/mailparser/rfc2183/scanner.rb
|
39
39
|
- lib/mailparser/rfc2183/parser.rb
|
40
|
-
- lib/mailparser/conv_charset.rb
|
41
|
-
- lib/mailparser/rfc2047.rb
|
42
40
|
- lib/mailparser/error.rb
|
43
|
-
- lib/mailparser/rfc2822.rb
|
44
41
|
- lib/mailparser/rfc2045/scanner.rb
|
45
42
|
- lib/mailparser/rfc2045/parser.rb
|
43
|
+
- lib/mailparser/rfc2047.rb
|
44
|
+
- lib/mailparser/conv_charset.rb
|
46
45
|
- lib/mailparser/loose.rb
|
47
46
|
- lib/mailparser/rfc2183.rb
|
47
|
+
- lib/mailparser/rfc2045.rb
|
48
|
+
- lib/mailparser/rfc2822.rb
|
48
49
|
- lib/mailparser/rfc2822/scanner.rb
|
49
50
|
- lib/mailparser/rfc2822/parser.rb
|
50
51
|
- lib/mailparser/rfc2231.rb
|
51
|
-
- lib/mailparser/rfc2045.rb
|
52
52
|
- test.rb
|
53
|
-
- test/test_rfc2183.rb
|
54
53
|
- test/test_loose.rb
|
55
|
-
- test/test_rfc2045.rb
|
56
54
|
- test/test_rfc2231.rb
|
57
|
-
- test/
|
55
|
+
- test/test_rfc2183.rb
|
58
56
|
- test/test_rfc2047.rb
|
59
57
|
- test/test_rfc2822.rb
|
58
|
+
- test/test_mailparser.rb
|
59
|
+
- test/test_rfc2045.rb
|
60
60
|
homepage: http://github.com/tmtm/mailparser
|
61
61
|
licenses:
|
62
62
|
- Ruby's
|
@@ -73,9 +73,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
73
73
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
74
|
none: false
|
75
75
|
requirements:
|
76
|
-
- - ! '
|
76
|
+
- - ! '>='
|
77
77
|
- !ruby/object:Gem::Version
|
78
|
-
version:
|
78
|
+
version: '0'
|
79
79
|
requirements: []
|
80
80
|
rubyforge_project:
|
81
81
|
rubygems_version: 1.8.23
|
@@ -84,11 +84,11 @@ specification_version: 3
|
|
84
84
|
summary: Mail Parser
|
85
85
|
test_files:
|
86
86
|
- test.rb
|
87
|
-
- test/test_rfc2183.rb
|
88
87
|
- test/test_loose.rb
|
89
|
-
- test/test_rfc2045.rb
|
90
88
|
- test/test_rfc2231.rb
|
91
|
-
- test/
|
89
|
+
- test/test_rfc2183.rb
|
92
90
|
- test/test_rfc2047.rb
|
93
91
|
- test/test_rfc2822.rb
|
92
|
+
- test/test_mailparser.rb
|
93
|
+
- test/test_rfc2045.rb
|
94
94
|
has_rdoc:
|