mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: new email attachment blacklists site settings
This commit is contained in:
@@ -436,11 +436,14 @@ module Email
|
||||
raise InvalidPostAction.new(e)
|
||||
end
|
||||
|
||||
|
||||
|
||||
def create_post_with_attachments(options={})
|
||||
# deal with attachments
|
||||
@mail.attachments.each do |attachment|
|
||||
# always strip S/MIME signatures
|
||||
next if attachment.content_type == "application/pkcs7-mime".freeze
|
||||
# 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")
|
||||
begin
|
||||
|
||||
@@ -5,10 +5,9 @@ module Validators; end
|
||||
class Validators::UploadValidator < ActiveModel::Validator
|
||||
|
||||
def validate(upload)
|
||||
# allow all attachments except S/MIME signatures
|
||||
# cf. https://meta.discourse.org/t/strip-s-mime-signatures/46371
|
||||
# check the attachment blacklist
|
||||
if upload.is_attachment_for_group_message && SiteSetting.allow_all_attachments_for_group_messages
|
||||
return upload.original_filename != "smime.p7s".freeze
|
||||
return upload.original_filename =~ SiteSetting.attachment_filename_blacklist_regex
|
||||
end
|
||||
|
||||
extension = File.extname(upload.original_filename)[1..-1] || ""
|
||||
|
||||
Reference in New Issue
Block a user