mailcvt 0.2.35 → 0.2.36
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/encoded_word.rb +12 -12
- data/lib/mailcvt/version.rb +1 -1
- metadata +1 -1
data/lib/encoded_word.rb
CHANGED
@@ -174,22 +174,22 @@ class EncodedWord
|
|
174
174
|
end
|
175
175
|
|
176
176
|
def word_decode(input, out_charset = 'utf-8')
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
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
|
+
begin
|
184
|
+
return wd.encode(out_charset, charset, :undef=>:replace, :invalid=>:replace)
|
185
|
+
rescue => e
|
186
|
+
puts "Cannot encode #{input} because #{e}, try iconv..."
|
183
187
|
begin
|
184
188
|
return Iconv.conv(out_charset + "//IGNORE", charset, wd)
|
185
189
|
rescue => e
|
186
|
-
puts "
|
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
|
190
|
+
puts "iconv failed too because #{e}."
|
192
191
|
return ''
|
193
192
|
end
|
193
|
+
end
|
194
194
|
end
|
195
195
|
end
|
data/lib/mailcvt/version.rb
CHANGED