mailcvt 0.2.32 → 0.2.33
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 +12 -7
- data/lib/mailcvt/version.rb +1 -1
- metadata +1 -1
data/lib/encoded_word.rb
CHANGED
@@ -173,12 +173,17 @@ class EncodedWord
|
|
173
173
|
end
|
174
174
|
|
175
175
|
def word_decode(input, out_charset = 'utf-8')
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
176
|
+
begin
|
177
|
+
u8 = input.encode('utf-8', @u8_enc, :undef=>:replace, :invalid=>:replace)
|
178
|
+
parts = u8.scan(/=\?([A-Za-z0-9_-]+)\?([BQbq])\?([^\?]+)\?=/).first
|
179
|
+
return input unless parts and parts.length == 3
|
180
|
+
charset = parts[0]
|
181
|
+
enc = parts[1].upcase
|
182
|
+
wd = parts[2].unpack({ "B"=>"m*", "Q"=>"M*" }[enc]).first
|
183
|
+
wd.encode(out_charset, charset, :undef=>:replace, :invalid=>:replace)
|
184
|
+
rescue => e
|
185
|
+
puts "Cannot decode #{input} because #{e}"
|
186
|
+
return ''
|
187
|
+
end
|
183
188
|
end
|
184
189
|
end
|
data/lib/mailcvt/version.rb
CHANGED