mailcvt 0.2.26 → 0.2.27
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/encoded_word.rb +27 -23
- data/lib/mailcvt/version.rb +1 -1
- metadata +1 -1
data/lib/encoded_word.rb
CHANGED
@@ -15,21 +15,21 @@ class EncodedWord
|
|
15
15
|
Dir.glob(File.join(@inputdir, File.join('**', '*.mlog'))).select do |f|
|
16
16
|
puts f
|
17
17
|
File.open(f + '.plain', 'w') do |out|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
18
|
+
File.open(f) do |input|
|
19
|
+
@input_enc = input.external_encoding
|
20
|
+
input.each_line do |line|
|
21
|
+
parts = mysplit(line)
|
22
|
+
newparts = []
|
23
|
+
newparts << format_date(parts[0]) #date
|
24
|
+
newparts << parts[1] #message-id
|
25
|
+
newparts << decode_subject(parts[2]) #subject
|
26
|
+
newparts << trim_emails(parts[3]) #from
|
27
|
+
newparts << trim_emails(parts[4]) #to
|
28
|
+
newparts << trim_emails(parts[5]) #cc
|
29
|
+
newparts << decode_attachments(parts[6]) unless parts.length == 6 #attachment
|
30
|
+
out.puts newparts.join("\t")
|
31
|
+
end
|
32
|
+
end
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
@@ -112,13 +112,17 @@ class EncodedWord
|
|
112
112
|
|
113
113
|
def mime_decode(input, out_charset = 'utf-8')
|
114
114
|
return '' unless input and input.length > 0
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
115
|
+
begin
|
116
|
+
ret = input.sub!(/=\?([A-Za-z0-9_-]+)\?([BQbq])\?([^\?]+)\?=/) {
|
117
|
+
charset = $1
|
118
|
+
enc = $2.upcase
|
119
|
+
word = $3
|
120
|
+
word = word.unpack({ "B"=>"m*", "Q"=>"M*" }[enc]).first
|
121
|
+
word.encode(out_charset, charset, :undef=>:replace, :invalid=>:replace)
|
122
|
+
}
|
123
|
+
return ret ? mime_decode(input) : input
|
124
|
+
rescue
|
125
|
+
return input
|
126
|
+
end
|
123
127
|
end
|
124
128
|
end
|
data/lib/mailcvt/version.rb
CHANGED