diff options
author | Claire <claire.github-309c@sitedethib.com> | 2023-07-06 15:05:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-06 15:05:05 +0200 |
commit | dc8f1fbd976ae544720a4e07120d9a91b2722440 (patch) | |
tree | 6402bf8a0edc3f970dd9b55896b0efe039a33787 /spec/models | |
parent | 6d8e0fae3e96f3cf4febe03fa7fcf5b95ff761b2 (diff) |
Merge pull request from GHSA-9928-3cp5-93fm
* Fix attachments getting processed despite failing content-type validation
* Add a restrictive ImageMagick security policy tailored for Mastodon
* Fix misdetection of MP3 files with large cover art
* Reject unprocessable audio/video files instead of keeping them unchanged
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/media_attachment_spec.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/models/media_attachment_spec.rb b/spec/models/media_attachment_spec.rb index 2dfc6cf9252..90e4f2f47b7 100644 --- a/spec/models/media_attachment_spec.rb +++ b/spec/models/media_attachment_spec.rb @@ -152,6 +152,26 @@ RSpec.describe MediaAttachment, paperclip_processing: true do end end + describe 'mp3 with large cover art' do + let(:media) { described_class.create(account: Fabricate(:account), file: attachment_fixture('boop.mp3')) } + + it 'detects it as an audio file' do + expect(media.type).to eq 'audio' + end + + it 'sets meta for the duration' do + expect(media.file.meta['original']['duration']).to be_within(0.05).of(0.235102) + end + + it 'extracts thumbnail' do + expect(media.thumbnail.present?).to be true + end + + it 'gives the file a random name' do + expect(media.file_file_name).to_not eq 'boop.mp3' + end + end + describe 'jpeg' do let(:media) { described_class.create(account: Fabricate(:account), file: attachment_fixture('attachment.jpg')) } |