Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F85823661
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/changelog.d/attachment-zero-size.fix b/changelog.d/attachment-zero-size.fix
new file mode 100644
index 000000000..dc42677c4
--- /dev/null
+++ b/changelog.d/attachment-zero-size.fix
@@ -0,0 +1 @@
+Do not crash when rendering attachments with zero width or height
diff --git a/test/pleroma/web/mastodon_api/views/status_view_test.exs b/test/pleroma/web/mastodon_api/views/status_view_test.exs
index f7b815ed7..1a0d7a3ce 100644
--- a/test/pleroma/web/mastodon_api/views/status_view_test.exs
+++ b/test/pleroma/web/mastodon_api/views/status_view_test.exs
@@ -597,6 +597,24 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
end
describe "attachments" do
+ test "skips meta for zero dimensions" do
+ for {width, height} <- [{0, 0}, {200, 0}, {0, 100}] do
+ object = %{
+ "type" => "Image",
+ "url" => [
+ %{
+ "mediaType" => "image/png",
+ "href" => "someurl",
+ "width" => width,
+ "height" => height
+ }
+ ]
+ }
+
+ refute Map.has_key?(StatusView.render("attachment.json", %{attachment: object}), :meta)
+ end
+ end
+
test "Complete Mastodon style" do
object = %{
"type" => "Image",
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Oct 29, 8:00 AM (15 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1797754
Default Alt Text
(1 KB)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline