mailcvt 0.2.26 → 0.2.27

Sign up to get free protection for your applications and to get access to all the features.
data/lib/encoded_word.rb CHANGED
@@ -15,21 +15,21 @@ 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
- input = File.open(f)
19
- @input_enc = input.external_encoding
20
- input.each_line do |line|
21
- #File.open(f, :internal_encoding => 'utf-8').each_line do |line|
22
- parts = mysplit(line)
23
- newparts = []
24
- newparts << format_date(parts[0]) #date
25
- newparts << parts[1] #message-id
26
- newparts << decode_subject(parts[2]) #subject
27
- newparts << trim_emails(parts[3]) #from
28
- newparts << trim_emails(parts[4]) #to
29
- newparts << trim_emails(parts[5]) #cc
30
- newparts << decode_attachments(parts[6]) unless parts.length == 6 #attachment
31
- out.puts newparts.join("\t")
32
- end
18
+ File.open(f) do |input|
19
+ @input_enc = input.external_encoding
20
+ input.each_line do |line|
21
+ parts = mysplit(line)
22
+ newparts = []
23
+ newparts << format_date(parts[0]) #date
24
+ newparts << parts[1] #message-id
25
+ newparts << decode_subject(parts[2]) #subject
26
+ newparts << trim_emails(parts[3]) #from
27
+ newparts << trim_emails(parts[4]) #to
28
+ newparts << trim_emails(parts[5]) #cc
29
+ newparts << decode_attachments(parts[6]) unless parts.length == 6 #attachment
30
+ out.puts newparts.join("\t")
31
+ end
32
+ end
33
33
  end
34
34
  end
35
35
  end
@@ -112,13 +112,17 @@ class EncodedWord
112
112
 
113
113
  def mime_decode(input, out_charset = 'utf-8')
114
114
  return '' unless input and input.length > 0
115
- ret = input.sub!(/=\?([A-Za-z0-9_-]+)\?([BQbq])\?([^\?]+)\?=/) {
116
- charset = $1
117
- enc = $2.upcase
118
- word = $3
119
- word = word.unpack({ "B"=>"m*", "Q"=>"M*" }[enc]).first
120
- word.encode(out_charset, charset, :undef=>:replace, :invalid=>:replace)
121
- }
122
- return ret ? mime_decode(input) : input
115
+ begin
116
+ ret = input.sub!(/=\?([A-Za-z0-9_-]+)\?([BQbq])\?([^\?]+)\?=/) {
117
+ charset = $1
118
+ enc = $2.upcase
119
+ word = $3
120
+ word = word.unpack({ "B"=>"m*", "Q"=>"M*" }[enc]).first
121
+ word.encode(out_charset, charset, :undef=>:replace, :invalid=>:replace)
122
+ }
123
+ return ret ? mime_decode(input) : input
124
+ rescue
125
+ return input
126
+ end
123
127
  end
124
128
  end
@@ -1,3 +1,3 @@
1
1
  module Mailcvt
2
- VERSION = '0.2.26'
2
+ VERSION = '0.2.27'
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.26
4
+ version: 0.2.27
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: