Fix HTML escape breaking some links.
authoreal <eal@waifu.club>
Thu, 7 Dec 2017 19:34:25 +0000 (21:34 +0200)
committereal <eal@waifu.club>
Thu, 7 Dec 2017 19:36:06 +0000 (21:36 +0200)
lib/pleroma/formatter.ex
lib/pleroma/web/common_api/utils.ex

index fbcbca9796e7e6dba95b9b32b8dba5a94d204a78..275c60f32634a705ff02bc82b6cdae2377f947a3 100644 (file)
@@ -24,6 +24,15 @@ defmodule Pleroma.Formatter do
     |> Enum.filter(fn ({_match, user}) -> user end)
   end
 
+  def html_escape(text) do
+    Regex.split(@link_regex, text, include_captures: true)
+    |> Enum.map_every(2, fn chunk ->
+      {:safe, part} = Phoenix.HTML.html_escape(chunk)
+      part
+    end)
+    |> Enum.join("")
+  end
+
   @finmoji [
     "a_trusted_friend",
     "alandislands",
index 1a23b1ad2abb9855ecccadf4c9978827cd552ead..f46db4cf08da8d72128b851b6acd0ddb592c61e2 100644 (file)
@@ -58,8 +58,8 @@ defmodule Pleroma.Web.CommonAPI.Utils do
   end
 
   def format_input(text, mentions, _tags) do
-    Phoenix.HTML.html_escape(text)
-    |> elem(1)
+    text
+    |> Formatter.html_escape
     |> Formatter.linkify
     |> String.replace("\n", "<br>")
     |> add_user_links(mentions)