Skip to content

Commit

Permalink
added support for body encoding, WARNING: Ruby 1.9 only
Browse files Browse the repository at this point in the history
  • Loading branch information
bluecat76 committed Aug 26, 2010
1 parent dee1339 commit d12e32a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
7 changes: 1 addition & 6 deletions lib/mail/body.rb
Expand Up @@ -46,7 +46,6 @@ def initialize(string = '')
end
end
@encoding = (only_us_ascii? ? '7bit' : '8bit')
set_charset
end

# Matches this body with another body. Also matches the decoded value of this
Expand Down Expand Up @@ -172,7 +171,7 @@ def decoded
if !Encodings.defined?(encoding)
raise UnknownEncodingType, "Don't know how to decode #{encoding}, please call #encoded and decode it yourself."
else
Encodings.get_encoding(encoding).decode(raw_source)
Encodings.get_encoding(encoding).decode(raw_source).force_encoding(@charset || "US-ASCII")
end
end

Expand Down Expand Up @@ -279,9 +278,5 @@ def crlf_boundary
def end_boundary
"\r\n\r\n--#{boundary}--\r\n"
end

def set_charset
only_us_ascii? ? @charset = 'US-ASCII' : @charset = nil
end
end
end
3 changes: 3 additions & 0 deletions lib/mail/message.rb
Expand Up @@ -1097,6 +1097,9 @@ def body=(value)
else
@body = Mail::Body.new(value)
end

@body.charset = @header.charset if @header.charset

add_encoding_to_body
end

Expand Down

0 comments on commit d12e32a

Please sign in to comment.