diff --git a/steal_emoji_policy.ex b/steal_emoji_policy.ex index 7d932d5..ffa837e 100644 --- a/steal_emoji_policy.ex +++ b/steal_emoji_policy.ex @@ -39,7 +39,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.StealEmojiPolicy do Logger.debug("HANDLING EMOJO") cond do - String.contains?(emojo_shortcode, "/") -> + !String.match?(emojo_shortcode, ~r/^[[:word:]]+$/) -> Logger.error("BAD EMOJO SHORTCODE: #{emojo_shortcode}") String.starts_with?(emojo_url, "https://") -> @@ -48,7 +48,11 @@ defmodule Pleroma.Web.ActivityPub.MRF.StealEmojiPolicy do if remote_emojo.status_code == 200 do with {:ok, current_dir} <- File.cwd() do - new_file = current_dir <> "/priv/static/emoji/stolen/" <> emojo_shortcode <> Path.extname(emojo_url) + emojo_uri = URI.parse(emojo_url) + extension = Path.extname(Path.basename(emojo_uri.path)) + filename = emojo_shortcode <> extension + + new_file = Path.join([current_dir, "priv/static/emoji/stolen", filename]) {:ok, file} = File.open(new_file, [:write]) IO.binwrite(file, remote_emojo.body)