summaryrefslogtreecommitdiff
path: root/app/controllers/concerns/send_file_upload.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-02-20 13:49:51 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-02-20 13:49:51 +0000
commit71786ddc8e28fbd3cb3fcc4b3ff15e5962a1c82e (patch)
tree6a2d93ef3fb2d353bb7739e4b57e6541f51cdd71 /app/controllers/concerns/send_file_upload.rb
parenta7253423e3403b8c08f8a161e5937e1488f5f407 (diff)
downloadgitlab-ce-71786ddc8e28fbd3cb3fcc4b3ff15e5962a1c82e.tar.gz
Add latest changes from gitlab-org/gitlab@15-9-stable-eev15.9.0-rc42
Diffstat (limited to 'app/controllers/concerns/send_file_upload.rb')
-rw-r--r--app/controllers/concerns/send_file_upload.rb23
1 files changed, 17 insertions, 6 deletions
diff --git a/app/controllers/concerns/send_file_upload.rb b/app/controllers/concerns/send_file_upload.rb
index c91edb74d6b..2141b257b40 100644
--- a/app/controllers/concerns/send_file_upload.rb
+++ b/app/controllers/concerns/send_file_upload.rb
@@ -63,21 +63,32 @@ module SendFileUpload
private
def image_scaling_request?(file_upload)
- avatar_safe_for_scaling?(file_upload) &&
- scaling_allowed_by_feature_flags?(file_upload) &&
- valid_image_scaling_width?
+ (avatar_safe_for_scaling?(file_upload) || pwa_icon_safe_for_scaling?(file_upload)) &&
+ scaling_allowed_by_feature_flags?(file_upload)
+ end
+
+ def pwa_icon_safe_for_scaling?(file_upload)
+ file_upload.try(:image_safe_for_scaling?) &&
+ mounted_as_pwa_icon?(file_upload) &&
+ valid_image_scaling_width?(Appearance::ALLOWED_PWA_ICON_SCALER_WIDTHS)
end
def avatar_safe_for_scaling?(file_upload)
- file_upload.try(:image_safe_for_scaling?) && mounted_as_avatar?(file_upload)
+ file_upload.try(:image_safe_for_scaling?) &&
+ mounted_as_avatar?(file_upload) &&
+ valid_image_scaling_width?(Avatarable::ALLOWED_IMAGE_SCALER_WIDTHS)
end
def mounted_as_avatar?(file_upload)
file_upload.try(:mounted_as)&.to_sym == :avatar
end
- def valid_image_scaling_width?
- Avatarable::ALLOWED_IMAGE_SCALER_WIDTHS.include?(params[:width]&.to_i)
+ def mounted_as_pwa_icon?(file_upload)
+ file_upload.try(:mounted_as)&.to_sym == :pwa_icon
+ end
+
+ def valid_image_scaling_width?(allowed_scalar_widths)
+ allowed_scalar_widths.include?(params[:width]&.to_i)
end
def scaling_allowed_by_feature_flags?(file_upload)