MIME.valid?(type) → is_bitstring(type) && MIME.extensions(type) != []
Since mime 1.6.0: warning: MIME.valid?/1 is deprecated. Use MIME.extensions(type) != [] instead As for the bitstring(type) part it's because MIME.extensions only expects a string. https://github.com/elixir-plug/mime/issues/43
This commit is contained in:
parent
24d66b60a0
commit
11844084d0
@ -61,7 +61,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.AttachmentValidator do
|
|||||||
def fix_media_type(data) do
|
def fix_media_type(data) do
|
||||||
data = Map.put_new(data, "mediaType", data["mimeType"])
|
data = Map.put_new(data, "mediaType", data["mimeType"])
|
||||||
|
|
||||||
if MIME.valid?(data["mediaType"]) do
|
if is_bitstring(data["mediaType"]) && MIME.extensions(data["mediaType"]) != [] do
|
||||||
data
|
data
|
||||||
else
|
else
|
||||||
Map.put(data, "mediaType", "application/octet-stream")
|
Map.put(data, "mediaType", "application/octet-stream")
|
||||||
|
@ -203,10 +203,17 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
|||||||
|
|
||||||
media_type =
|
media_type =
|
||||||
cond do
|
cond do
|
||||||
is_map(url) && MIME.valid?(url["mediaType"]) -> url["mediaType"]
|
is_map(url) && MIME.extensions(url["mediaType"]) != [] ->
|
||||||
MIME.valid?(data["mediaType"]) -> data["mediaType"]
|
url["mediaType"]
|
||||||
MIME.valid?(data["mimeType"]) -> data["mimeType"]
|
|
||||||
true -> nil
|
is_bitstring(data["mediaType"]) && MIME.extensions(data["mediaType"]) != [] ->
|
||||||
|
data["mediaType"]
|
||||||
|
|
||||||
|
is_bitstring(data["mimeType"]) && MIME.extensions(data["mimeType"]) != [] ->
|
||||||
|
data["mimeType"]
|
||||||
|
|
||||||
|
true ->
|
||||||
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
href =
|
href =
|
||||||
|
Loading…
Reference in New Issue
Block a user