attachments 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/lib/attachments/extract.rb +11 -3
  3. metadata +3 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -99,16 +99,24 @@ module Attachments
99
99
  filename = "#{@name}.#{uuid}"
100
100
  filepath = "/tmp/#{filename}"
101
101
 
102
+
102
103
  body = case ct
103
104
  when "text/plain" then
104
105
  m = mail.body.decoded
106
+ if charset && charset.match(/charset=/i)
107
+ charset.gsub!(/charset=/i, "")
108
+ charset.strip!
109
+ else
110
+ charset = nil
111
+ end
105
112
  begin
113
+ if charset
114
+ m.force_encoding(charset)
115
+ end
106
116
  m.encode("utf-8")
107
117
  rescue
108
118
  # Ruby 1.8 doesn't know encode
109
- if charset && charset.match(/charset=/i)
110
- charset.gsub!(/charset=/i, "")
111
- charset.strip!
119
+ if charset
112
120
  Iconv.conv("utf-8", charset, m)
113
121
  else
114
122
  m
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attachments
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Rune Myrland