mailcvt 0.2.25 → 0.2.26

Sign up to get free protection for your applications and to get access to all the features.
data/lib/encoded_word.rb CHANGED
@@ -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.open(f, :internal_encoding => 'utf-8').each_line do |line|
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|
19
22
  parts = mysplit(line)
20
23
  newparts = []
21
24
  newparts << format_date(parts[0]) #date
@@ -60,12 +63,14 @@ class EncodedWord
60
63
 
61
64
  def decode_subject(sub)
62
65
  return '' unless sub and sub.length > 0
66
+ sub = sub.encode('utf-8', @input_enc, :undef=>:replace, :invalid=>:replace)
63
67
  one = sub.gsub("\a", '')
64
68
  mime_decode(one)
65
69
  end
66
70
 
67
71
  def trim_emails(emails)
68
72
  return '' unless emails and emails.length > 0
73
+ emails = emails.encode('utf-8', @input_enc, :undef=>:replace, :invalid=>:replace)
69
74
  pos1 = -1
70
75
  newparts = []
71
76
  while true do
@@ -96,6 +101,7 @@ class EncodedWord
96
101
 
97
102
  def decode_attachments(attachments)
98
103
  return '' unless attachments and attachments.length > 0
104
+ attachments = attachments.encode('utf-8', @input_enc, :undef=>:replace, :invalid=>:replace)
99
105
  parts = mysplit(attachments, "\a")
100
106
  newparts = []
101
107
  parts.each do |p|
@@ -1,3 +1,3 @@
1
1
  module Mailcvt
2
- VERSION = '0.2.25'
2
+ VERSION = '0.2.26'
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.25
4
+ version: 0.2.26
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: