logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://anongit.hacktivis.me/git/pleroma.git/
commit: 80e0f072407728d06fd931ebebca8fd91cc80918
parent 4eeb9c1f2d2e53228db25c83de2eb1837585c56c
Author: Lain Soykaf <lain@lain.com>
Date:   Fri,  8 Aug 2025 15:44:30 +0400

Emoji.Pack: Implement empty name and directory creation failure handling

Diffstat:

Mlib/pleroma/emoji/pack.ex10+++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lib/pleroma/emoji/pack.ex b/lib/pleroma/emoji/pack.ex @@ -230,15 +230,23 @@ defmodule Pleroma.Emoji.Pack do :ok <- validate_new_pack(name), {:ok, archive_data} <- fetch_archive_data(opts), pack_path <- path_join_name_safe(emoji_path(), name), - :ok <- File.mkdir_p(pack_path), + :ok <- create_pack_dir(pack_path), :ok <- safe_unzip(archive_data, pack_path) do ensure_pack_json(pack_path, archive_data, opts) else + {:error, :empty_values} -> {:error, "Pack name cannot be empty"} {:error, reason} when is_binary(reason) -> {:error, reason} _ -> {:error, "Could not process pack"} end end + defp create_pack_dir(pack_path) do + case File.mkdir_p(pack_path) do + :ok -> :ok + {:error, _} -> {:error, "Could not create the pack directory"} + end + end + defp safe_unzip(archive_data, pack_path) do case SafeZip.unzip_data(archive_data, pack_path) do {:ok, _} -> :ok