Sanitize all input to help with icky emails

This commit is contained in:
Eric Allen 2008-09-20 19:20:08 -07:00
parent ca4255332f
commit 2fda252378

View file

@ -1,4 +1,5 @@
class MessageGateway < ActionMailer::Base
include ActionView::Helpers::SanitizeHelper
def receive(email)
user = User.find(:first, :include => [:preference], :conditions => ["preferences.sms_email = ?", email.from[0].strip])
if user.nil?
@ -11,16 +12,16 @@ class MessageGateway < ActionMailer::Base
notes = nil
if email.content_type == "multipart/related"
description = email.subject
description = sanitize email.subject
body_part = email.parts.find{|m| m.content_type == "text/plain"}
notes = body_part.body.strip
notes = sanitize body_part.body.strip
else
if email.subject.empty?
description = email.body.strip
description = sanitize email.body.strip
notes = nil
else
description = email.subject.strip
notes = email.body.strip
description = sanitize email.subject.strip
notes = sanitize email.body.strip
end
end