mailcvt 0.2.22 → 0.2.23

Sign up to get free protection for your applications and to get access to all the features.
@@ -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.readlines(f).each do |line|
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
- begin
110
- ret = input.sub!(/=\?([A-Za-z0-9_-]+)\?([BQbq])\?([^\?]+)\?=/) {
111
- charset = $1
112
- enc = $2.upcase
113
- word = $3
114
- word = word.unpack({ "B"=>"m*", "Q"=>"M*" }[enc]).first
115
- word.encode(out_charset, charset, :undef=>:replace, :invalid=>:replace)
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
@@ -1,3 +1,3 @@
1
1
  module Mailcvt
2
- VERSION = '0.2.22'
2
+ VERSION = '0.2.23'
3
3
  end
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.22
4
+ version: 0.2.23
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: