Fix ogg vorbis files with a cover art not being correctly processed #14255
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Paperclip runs files through a “spoof detector” to figure out whether they correspond to their advertised content-type.
In #14184, we have overridden part of that detection because it relied on the
file
utility which returnsapplication/octet-stream
for some mp3 files, and usedMimeMagic
instead.However,
MimeMagic
detects Ogg Vorbis files with a cover art asvideo/ogg
, whilefile
correctly detects it asaudio/ogg
. This causes a mismatch when the file has an.oga
extension, which is explicitlyaudio/ogg
.Furthermore, this leads to Ogg Vorbis files submitted with the
.ogg
and a cover art to not be correctly processed, failing to extract a thumbnail and converting them to.mp3
. This is because the first validation passes interpreting it as avideo/ogg
file while our code later constructs a.oga
extension based on the correctly detectedaudio/ogg
, causing the actual processing to be skipped because of the mismatch.This PR changes the detector to allow the validation to pass if it matches either
FileMagic
orfile
's output.