mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-05 22:44:22 +08:00
Improve regexp for image whitelisting [SCI-736]
This commit is contained in:
parent
74f6455a8f
commit
cc0aab2e59
2 changed files with 5 additions and 4 deletions
|
@ -114,8 +114,9 @@ class AssetsController < ApplicationController
|
||||||
fields: s3_post.fields
|
fields: s3_post.fields
|
||||||
})
|
})
|
||||||
|
|
||||||
if (asset.file_content_type =~
|
condition = %r{^image/#{Regexp.union(Constants::WHITELISTED_IMAGE_TYPES)}}
|
||||||
%r{/^image\/#{Constants::WHITELISTED_IMAGE_TYPES.join("|")}/}) == 0
|
|
||||||
|
if condition === asset.file_content_type
|
||||||
asset.file.options[:styles].each do |style, option|
|
asset.file.options[:styles].each do |style, option|
|
||||||
s3_post = S3_BUCKET.presigned_post(
|
s3_post = S3_BUCKET.presigned_post(
|
||||||
key: asset.file.path(style)[1..-1],
|
key: asset.file.path(style)[1..-1],
|
||||||
|
|
|
@ -138,8 +138,8 @@ class Asset < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_image?
|
def is_image?
|
||||||
!(file.content_type =~
|
%r{^image/#{Regexp.union(Constants::WHITELISTED_IMAGE_TYPES)}} ===
|
||||||
%r{/^image\/#{Constants::WHITELISTED_IMAGE_TYPES.join("|")}/}).nil?
|
file.content_type
|
||||||
end
|
end
|
||||||
|
|
||||||
def text?
|
def text?
|
||||||
|
|
Loading…
Reference in a new issue