mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
FIX: strip blacklisted attachments before checking for empty email body
This commit is contained in:
parent
17b51bb465
commit
5c06076b5c
1 changed files with 9 additions and 7 deletions
|
@ -77,7 +77,7 @@ module Email
|
||||||
body, @elided = select_body
|
body, @elided = select_body
|
||||||
body ||= ""
|
body ||= ""
|
||||||
|
|
||||||
raise NoBodyDetectedError if body.blank? && !@mail.has_attachments?
|
raise NoBodyDetectedError if body.blank? && attachments.empty?
|
||||||
|
|
||||||
if is_auto_generated?
|
if is_auto_generated?
|
||||||
@incoming_email.update_columns(is_auto_generated: true)
|
@incoming_email.update_columns(is_auto_generated: true)
|
||||||
|
@ -436,15 +436,17 @@ module Email
|
||||||
raise InvalidPostAction.new(e)
|
raise InvalidPostAction.new(e)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def attachments
|
||||||
|
# strip blacklisted attachments (mostly signatures)
|
||||||
|
@attachments ||= @mail.attachments.select do |attachment|
|
||||||
|
attachment.content_type !~ SiteSetting.attachment_content_type_blacklist_regex &&
|
||||||
|
attachment.filename !~ SiteSetting.attachment_filename_blacklist_regex
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def create_post_with_attachments(options={})
|
def create_post_with_attachments(options={})
|
||||||
# deal with attachments
|
# deal with attachments
|
||||||
@mail.attachments.each do |attachment|
|
attachments.each do |attachment|
|
||||||
# strip blacklisted attachments (mostly signatures)
|
|
||||||
next if attachment.content_type =~ SiteSetting.attachment_content_type_blacklist_regex
|
|
||||||
next if attachment.filename =~ SiteSetting.attachment_filename_blacklist_regex
|
|
||||||
|
|
||||||
tmp = Tempfile.new("discourse-email-attachment")
|
tmp = Tempfile.new("discourse-email-attachment")
|
||||||
begin
|
begin
|
||||||
# read attachment
|
# read attachment
|
||||||
|
|
Loading…
Reference in a new issue