Modify newlines.
[akkoma] / lib / pleroma / gopher / server.ex
index 6a72e8dd0393405ca13f669c426f5a9ea972ea29..bf87e51ec2a300efe46e4a1b8a9979ee88119ffe 100644 (file)
@@ -50,8 +50,12 @@ defmodule Pleroma.Gopher.Server.ProtocolHandler do
   end
 
   def info(text) do
-    text = String.replace(text, ~r/[\t\r\n]/, " ")
-    "#{text}\tfake\(NULL)\t0\r\n"
+    text = String.replace(text, ~r/[\t\n]/, " ")
+    String.split(text, "\r")
+    |> Enum.map(fn (text) ->
+      "i#{text}\tfake\(NULL)\t0\r\n"
+    end)
+    |> Enum.join("")
   end
 
   def link(name, selector, type \\ 1) do
@@ -78,7 +82,7 @@ defmodule Pleroma.Gopher.Server.ProtocolHandler do
 
       link("Post ##{activity.id} by #{user.nickname}", "/notices/#{activity.id}") <>
         info("#{like_count} likes, #{announcement_count} repeats") <>
-        "\r\n" <> info(HtmlSanitizeEx.strip_tags(activity.data["object"]["content"]))
+        "\r\n" <> info(HtmlSanitizeEx.strip_tags(String.replace(activity.data["object"]["content"], "<br>", "\n"))
     end)
     |> Enum.join("\r\n")
   end