Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-06 06:09:23 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-06 06:09:23 +0300
commitf098e6d3d2c8eaaec0a228c8a3ae01f770e15dd2 (patch)
tree611a38154ba90341f6c6935a51cf7962f5896790 /lib
parent697d1c4e06d1c232ca8b21805cc889a0991702ab (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/email/attachment_uploader.rb15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/gitlab/email/attachment_uploader.rb b/lib/gitlab/email/attachment_uploader.rb
index d8962ec0d20..70e281fd4a3 100644
--- a/lib/gitlab/email/attachment_uploader.rb
+++ b/lib/gitlab/email/attachment_uploader.rb
@@ -39,15 +39,22 @@ module Gitlab
# from the uploaded attachments
def filter_signature_attachments(message)
attachments = message.attachments
+ content_type = normalize_mime(message.content_type)
+ protocol = normalize_mime(message.content_type_parameters[:protocol])
- if message.content_type&.starts_with?('multipart/signed')
- signature_protocol = message.content_type_parameters[:protocol]
-
- attachments.delete_if { |attachment| attachment.content_type.starts_with?(signature_protocol) } if signature_protocol.present?
+ if content_type == 'multipart/signed' && protocol
+ attachments.delete_if { |attachment| protocol == normalize_mime(attachment.content_type) }
end
attachments
end
+
+ # normalizes mime-type ignoring case and removing extra data
+ # also removes potential "x-" prefix from subtype, since some MUAs mix them
+ # e.g. "application/x-pkcs7-signature" with "application/pkcs7-signature"
+ def normalize_mime(content_type)
+ MIME::Type.simplified(content_type, remove_x_prefix: true)
+ end
end
end
end