mailcvt 0.2.33 → 0.2.34
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/encoded_word.rb +12 -6
- data/lib/mailcvt/version.rb +1 -1
- metadata +17 -1
data/lib/encoded_word.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'base64'
|
3
3
|
require 'date'
|
4
|
+
require 'iconv'
|
4
5
|
|
5
6
|
class EncodedWord
|
6
7
|
def initialize(inputdir)
|
@@ -173,17 +174,22 @@ class EncodedWord
|
|
173
174
|
end
|
174
175
|
|
175
176
|
def word_decode(input, out_charset = 'utf-8')
|
176
|
-
begin
|
177
177
|
u8 = input.encode('utf-8', @u8_enc, :undef=>:replace, :invalid=>:replace)
|
178
178
|
parts = u8.scan(/=\?([A-Za-z0-9_-]+)\?([BQbq])\?([^\?]+)\?=/).first
|
179
179
|
return input unless parts and parts.length == 3
|
180
180
|
charset = parts[0]
|
181
181
|
enc = parts[1].upcase
|
182
182
|
wd = parts[2].unpack({ "B"=>"m*", "Q"=>"M*" }[enc]).first
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
183
|
+
begin
|
184
|
+
return Iconv.conv(out_charset + "//IGNORE", charset, wd)
|
185
|
+
rescue => e
|
186
|
+
puts "Cannot iconv #{input} because #{e}, try encode."
|
187
|
+
begin
|
188
|
+
return wd.encode(out_charset, charset, :undef=>:replace, :invalid=>:replace)
|
189
|
+
rescue => e
|
190
|
+
puts "Cannot encode #{input} because #{e}"
|
191
|
+
end
|
192
|
+
return ''
|
193
|
+
end
|
188
194
|
end
|
189
195
|
end
|
data/lib/mailcvt/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mailcvt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.34
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -75,6 +75,22 @@ dependencies:
|
|
75
75
|
- - '='
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: 2.7.0
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: iconv
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - '='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 1.0.3
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - '='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 1.0.3
|
78
94
|
description:
|
79
95
|
email: jiapeng.com@gmail.com
|
80
96
|
executables:
|