AttachmentValidator: Check if the mime type is valid.
authorlain <lain@soykaf.club>
Sun, 7 Jun 2020 07:19:00 +0000 (09:19 +0200)
committerlain <lain@soykaf.club>
Sun, 7 Jun 2020 07:19:00 +0000 (09:19 +0200)
lib/pleroma/web/activity_pub/object_validators/attachment_validator.ex

index c4b502cb971ac75ce0a45aa517e7a8da1904e4f8..f53bb02bec8d3261ec76e00cf1948b4907fb5c9e 100644 (file)
@@ -45,11 +45,11 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.AttachmentValidator do
       data
       |> Map.put_new("mediaType", data["mimeType"])
 
-    if data["mediaType"] == "" do
+    if MIME.valid?(data["mediaType"]) do
       data
-      |> Map.put("mediaType", "application/octet-stream")
     else
       data
+      |> Map.put("mediaType", "application/octet-stream")
     end
   end