Merge pull request #2170 from urbanrotnik/ur-sci-4008-rte-image-download

Fix for downloading image [SCI-4008]
This commit is contained in:
Urban Rotnik 2019-10-22 15:12:11 +02:00 committed by GitHub
commit 169a381629
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View file

@ -24,7 +24,7 @@ tinymce.PluginManager.add('custom_image_toolbar', function(editor) {
});
function isImage(elem) {
return editor.dom.is(elem, 'img');
return editor.dom.is(elem, 'img') && elem.dataset.mceToken;
}
function isMarvinJs(elem) {
return elem.dataset.sourceType === 'marvinjs';

View file

@ -96,8 +96,14 @@ module TinyMceImages
else
# We need implement size and type checks here
new_image = URI.parse(image['src']).open
new_image_filename = asset.class.generate_unique_secure_token + '.jpg'
url = image['src']
image_type = FastImage.type(url).to_s
next unless image_type
new_image = URI.parse(url).open
next if new_image.size > Rails.configuration.x.file_max_size_mb.megabytes
new_image_filename = Asset.generate_unique_secure_token + '.' + image_type
end
new_asset = TinyMceAsset.create(