Mime: detect RIFF formats (wave, webp, avi)
authorhref <href@random.sh>
Mon, 4 Feb 2019 16:44:41 +0000 (17:44 +0100)
committerhref <href@random.sh>
Mon, 4 Feb 2019 16:44:41 +0000 (17:44 +0100)
lib/pleroma/mime.ex

index 84fb536e0630644f94e492302ae34333eaec096e..36771533f01336c8331ebd7d989273437212228d 100644 (file)
@@ -102,10 +102,18 @@ defmodule Pleroma.MIME do
     "audio/ogg"
   end
 
-  defp check_mime_type(<<0x52, 0x49, 0x46, 0x46, _::binary>>) do
+  defp check_mime_type(<<"RIFF", _::binary-size(4), "WAVE", _::binary>>) do
     "audio/wav"
   end
 
+  defp check_mime_type(<<"RIFF", _::binary-size(4), "WEBP", _::binary>>) do
+    "image/webp"
+  end
+
+  defp check_mime_type(<<"RIFF", _::binary-size(4), "AVI.", _::binary>>) do
+    "video/avi"
+  end
+
   defp check_mime_type(_) do
     @default
   end