diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tmail_extensions.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/tmail_extensions.rb b/lib/tmail_extensions.rb index 6e214df0e..89f5a7df3 100644 --- a/lib/tmail_extensions.rb +++ b/lib/tmail_extensions.rb @@ -6,6 +6,9 @@ # # $Id: tmail_extensions.rb,v 1.7 2009-10-02 23:31:01 francis Exp $ +require 'tmail' +require 'tmail/interface' + # Monkeypatch! # These mainly used in app/models/incoming_message.rb @@ -35,6 +38,28 @@ module TMail val = self.header_string('envelope-to') return val ? [val,] : [] end + + # Bug fix to this function - is for message in humberside-police-odd-mime-type.email + # Which was originally: https://secure.mysociety.org/admin/foi/request/show_raw_email/11209 + # See test in spec/lib/tmail_extensions.rb + def set_content_type( str, sub = nil, param = nil ) + if sub + main, sub = str, sub + else + main, sub = str.split(%r</>, 2) + raise ArgumentError, "sub type missing: #{str.inspect}" unless sub + end + if h = @header['content-type'] + h.main_type = main + h.sub_type = sub + h.params.clear # if !h.params.nil? # XXX this if statement is the fix # XXX disabled until works with test + else + store 'Content-Type', "#{main}/#{sub}" + end + @header['content-type'].params.replace param if param + str + end + end class Address |