Pleroma.Formatter: width/height to class=emoji
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Thu, 7 Feb 2019 15:41:20 +0000 (16:41 +0100)
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Fri, 3 May 2019 14:25:58 +0000 (16:25 +0200)
lib/pleroma/formatter.ex
lib/pleroma/html.ex
test/formatter_test.exs
test/web/twitter_api/views/activity_view_test.exs
test/web/twitter_api/views/user_view_test.exs

index dab8910c199b2dcc23cbe6ed96c1b7ab4313d72e..0ec6bcee013dd673867bb2673bd7a2cfc53a16f4 100644 (file)
@@ -113,9 +113,7 @@ defmodule Pleroma.Formatter do
 
       html =
         if not strip do
-          "<img height='32px' width='32px' alt='#{emoji}' title='#{emoji}' src='#{
-            MediaProxy.url(file)
-          }' />"
+          "<img class='emoji' alt='#{emoji}' title='#{emoji}' src='#{MediaProxy.url(file)}' />"
         else
           ""
         end
index 726c370ad7a66ba34f7089b51ba82001c2bad265..d1da746de0c781d6bd08a386641cad36492c9fd4 100644 (file)
@@ -151,6 +151,7 @@ defmodule Pleroma.HTML.Scrubber.TwitterText do
     Meta.allow_tag_with_these_attributes("img", [
       "width",
       "height",
+      "class",
       "title",
       "alt"
     ])
@@ -221,6 +222,7 @@ defmodule Pleroma.HTML.Scrubber.Default do
     Meta.allow_tag_with_these_attributes("img", [
       "width",
       "height",
+      "class",
       "title",
       "alt"
     ])
index fdaf297424dc10d8220e7c17f450f69fe6dfa6cf..06f4f6e50d57241d349b17c2805ab7d8860646c1 100644 (file)
@@ -248,7 +248,7 @@ defmodule Pleroma.FormatterTest do
     text = "I love :firefox:"
 
     expected_result =
-      "I love <img height=\"32px\" width=\"32px\" alt=\"firefox\" title=\"firefox\" src=\"/emoji/Firefox.gif\" />"
+      "I love <img class=\"emoji\" alt=\"firefox\" title=\"firefox\" src=\"/emoji/Firefox.gif\" />"
 
     assert Formatter.emojify(text) == expected_result
   end
@@ -263,7 +263,7 @@ defmodule Pleroma.FormatterTest do
     }
 
     expected_result =
-      "I love <img height=\"32px\" width=\"32px\" alt=\"\" title=\"\" src=\"https://placehold.it/1x1\" />"
+      "I love <img class=\"emoji\" alt=\"\" title=\"\" src=\"https://placehold.it/1x1\" />"
 
     assert Formatter.emojify(text, custom_emoji) == expected_result
   end
index 85815ba7e98a8028409fe84abdec421b0cb37718..1aa533b48720a6bf705190fa9597cd216178b3ab 100644 (file)
@@ -100,7 +100,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do
     expected = ":firefox: meow"
 
     expected_html =
-      "<img height=\"32px\" width=\"32px\" alt=\"firefox\" title=\"firefox\" src=\"http://localhost:4001/emoji/Firefox.gif\" /> meow"
+      "<img class=\"emoji\" alt=\"firefox\" title=\"firefox\" src=\"http://localhost:4001/emoji/Firefox.gif\" /> meow"
 
     assert result["summary"] == expected
     assert result["summary_html"] == expected_html
index c99dbddeb355630cb4819ec23b26f0130fa0452f..74526673c2959034b72b84618bbc194be36fd1ad 100644 (file)
@@ -32,7 +32,7 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
 
   test "A user with emoji in username" do
     expected =
-      "<img height=\"32px\" width=\"32px\" alt=\"karjalanpiirakka\" title=\"karjalanpiirakka\" src=\"/file.png\" /> man"
+      "<img class=\"emoji\" alt=\"karjalanpiirakka\" title=\"karjalanpiirakka\" src=\"/file.png\" /> man"
 
     user =
       insert(:user, %{