Description
Trying to detect the MIME type of an ogg vorbis file returns audio/vorbis
, which according to https://wiki.xiph.org/MIME_Types_and_File_Extensions is for vorbis streams without containers, instead of audio/ogg
.
irb(main):003:0> Marcel::Magic.by_magic(File.open('spec/fixtures/files/boop.ogg'))
=> #<Marcel::Magic:0x0000560870431ec0 @mediatype="audio", @subtype="vorbis", @type="audio/vorbis">
irb(main):002:0> Marcel::MimeType.for(Pathname.new('spec/fixtures/files/boop.ogg'))
=> "audio/vorbis"
irb(main):004:0> Marcel::MimeType.for(File.open('spec/fixtures/files/boop.ogg'), name: 'boop.ogg')
=> "audio/vorbis"
This is a bit surprising and might throw some tools off, as audio/vorbis
is generally not expected nor associated with any file format of extension (since it's for streams themselves and not files/containers).
Passing declared_type
works but it might not be provider, or provided by an untrusted source:
irb(main):006:0> Marcel::MimeType.for(File.open('spec/fixtures/files/boop.ogg'), name: 'boop.ogg', declared_type: 'audio/ogg')
=> "audio/ogg"
EDIT: this seems to come from https://github.com/rails/marcel/blob/main/data/tika.xml#L5135-L5146 and introduced in Apache Tika by apache/tika@41c6749 but I do think it's wrong, as audio/vorbis
seem to be defined by RFC5215 and specific to RTP streams.