mailcvt 0.2.22 → 0.2.23
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 +13 -13
- data/lib/mailcvt/version.rb +1 -1
- metadata +1 -1
data/lib/encoded_word.rb
CHANGED
@@ -15,7 +15,10 @@ 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
|
-
File.
|
18
|
+
File.open(f) do |file|
|
19
|
+
f.each_line do |line|
|
20
|
+
line = line.encode('utf-8', file.external_encoding.name,
|
21
|
+
:undef=>:replace, :invalid=>:replace)
|
19
22
|
parts = mysplit(line)
|
20
23
|
newparts = []
|
21
24
|
newparts << format_date(parts[0]) #date
|
@@ -28,6 +31,7 @@ class EncodedWord
|
|
28
31
|
out.puts newparts.join("\t")
|
29
32
|
end
|
30
33
|
end
|
34
|
+
end
|
31
35
|
end
|
32
36
|
end
|
33
37
|
|
@@ -106,17 +110,13 @@ class EncodedWord
|
|
106
110
|
|
107
111
|
def mime_decode(input, out_charset = 'utf-8')
|
108
112
|
return '' unless input and input.length > 0
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
return ret ? mime_decode(input) : input
|
118
|
-
rescue
|
119
|
-
return input
|
120
|
-
end
|
113
|
+
ret = input.sub!(/=\?([A-Za-z0-9_-]+)\?([BQbq])\?([^\?]+)\?=/) {
|
114
|
+
charset = $1
|
115
|
+
enc = $2.upcase
|
116
|
+
word = $3
|
117
|
+
word = word.unpack({ "B"=>"m*", "Q"=>"M*" }[enc]).first
|
118
|
+
word.encode(out_charset, charset, :undef=>:replace, :invalid=>:replace)
|
119
|
+
}
|
120
|
+
return ret ? mime_decode(input) : input
|
121
121
|
end
|
122
122
|
end
|
data/lib/mailcvt/version.rb
CHANGED