mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
FIX: Only mark attachments as secure media if SiteSetting.secure_media? (#9009)
* Attachments (non media files) were being marked as secure if just SiteSetting.prevent_anons_from_downloading_files was enabled. this was not correct as nothing should be marked as actually "secure" in the DB without that site setting enabled * Also add a proper standalone spec file for the upload security class
This commit is contained in:
@ -21,8 +21,9 @@ class UploadSecurity
|
||||
end
|
||||
|
||||
def should_be_secure?
|
||||
return false if !SiteSetting.secure_media?
|
||||
return false if uploading_in_public_context?
|
||||
secure_attachment? || secure_media?
|
||||
(secure_attachment? || supported_media?) && uploading_in_secure_context?
|
||||
end
|
||||
|
||||
private
|
||||
@ -39,10 +40,6 @@ class UploadSecurity
|
||||
!supported_media? && SiteSetting.prevent_anons_from_downloading_files
|
||||
end
|
||||
|
||||
def secure_media?
|
||||
SiteSetting.secure_media? && supported_media? && uploading_in_secure_context?
|
||||
end
|
||||
|
||||
def uploading_in_secure_context?
|
||||
return true if SiteSetting.login_required?
|
||||
if @upload.access_control_post_id.present?
|
||||
|
Reference in New Issue
Block a user