From dfe62a251903f49bc7c1fee68efff1511b12e374 Mon Sep 17 00:00:00 2001 From: Francis Irving Date: Wed, 2 Dec 2009 23:05:26 +0000 Subject: Test for TMail fix for a particular message. Monkey patch doesn't quite work yet. --- lib/tmail_extensions.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'lib/tmail_extensions.rb') 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 -- cgit v1.2.3