Don't insert newlines to generated HTML.
authoreal <eal@waifu.club>
Sat, 18 Nov 2017 12:46:54 +0000 (14:46 +0200)
committereal <eal@waifu.club>
Sat, 18 Nov 2017 12:46:54 +0000 (14:46 +0200)
MastoFE doesn't like them.

lib/pleroma/web/common_api/utils.ex
test/web/common_api/common_api_utils_test.exs
test/web/twitter_api/twitter_api_test.exs

index 21b6226b1d82cf2d81da73f40f7cf490577c06a4..7cce77b10d2fd0ca0caadf776b110e6851a4a377 100644 (file)
@@ -54,14 +54,14 @@ defmodule Pleroma.Web.CommonAPI.Utils do
         "<a href=\"#{href}\" class='attachment'>#{shortname(name)}</a>"
       _ -> ""
     end)
-    Enum.join([text | attachment_text], "<br>\n")
+    Enum.join([text | attachment_text], "<br>")
   end
 
   def format_input(text, mentions, tags) do
     Phoenix.HTML.html_escape(text)
     |> elem(1)
     |> Formatter.linkify
-    |> String.replace("\n", "<br>\n")
+    |> String.replace("\n", "<br>")
     |> add_user_links(mentions)
     # |> add_tag_links(tags)
   end
index a159c08355255d4831c0b054466b45fec1d79de8..f6a7da9edf31741ba88ef0643c826e8f362e2e49 100644 (file)
@@ -11,6 +11,6 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do
 
     res = Utils.add_attachments("", [attachment])
 
-    assert res == "<br>\n<a href=\"#{name}\" class='attachment'>Sakura Mana – Turned on by a Se…</a>"
+    assert res == "<br><a href=\"#{name}\" class='attachment'>Sakura Mana – Turned on by a Se…</a>"
   end
 end
index 8698686ad88b472ad00be7f11a34e39e2526198d..06ecd9e752e3b8e1f0c4171a068c5d940e0d7fa5 100644 (file)
@@ -34,7 +34,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
 
     { :ok, activity = %Activity{} } = TwitterAPI.create_status(user, input)
 
-    assert get_in(activity.data, ["object", "content"]) == "Hello again, <a href='shp'>@shp</a>.&lt;script&gt;&lt;/script&gt;<br>\nThis is on another line. #2hu #epic #phantasmagoric<br>\n<a href=\"http://example.org/image.jpg\" class='attachment'>image.jpg</a>"
+    assert get_in(activity.data, ["object", "content"]) == "Hello again, <a href='shp'>@shp</a>.&lt;script&gt;&lt;/script&gt;<br>This is on another line. #2hu #epic #phantasmagoric<br><a href=\"http://example.org/image.jpg\" class='attachment'>image.jpg</a>"
     assert get_in(activity.data, ["object", "type"]) == "Note"
     assert get_in(activity.data, ["object", "actor"]) == user.ap_id
     assert get_in(activity.data, ["actor"]) == user.ap_id