X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fformatter.ex;h=456416fbdff4eecc6127ee9ea36bbd486cc6ecd7;hb=4d2c6707c2f5f7723f1fcf03cdbf9476f2d5b3ad;hp=9396b182682cd2dd99b4b35b8341e68df20b8970;hpb=4afbef39f49948ddd3b1cd1bbda58ff7e3ac2785;p=akkoma
diff --git a/lib/pleroma/formatter.ex b/lib/pleroma/formatter.ex
index 9396b1826..456416fbd 100644
--- a/lib/pleroma/formatter.ex
+++ b/lib/pleroma/formatter.ex
@@ -144,7 +144,7 @@ defmodule Pleroma.Formatter do
@emoji
end
- @link_regex ~r/https?:\/\/[\w\.\/?=\-#%&@~\(\)]+[\w\/]/u
+ @link_regex ~r/https?:\/\/[\w\.\/?=\-#\+%&@~'\(\):]+[\w\/]/u
def html_escape(text) do
Regex.split(@link_regex, text, include_captures: true)
@@ -168,7 +168,13 @@ defmodule Pleroma.Formatter do
subs =
subs ++
Enum.map(links, fn {uuid, url} ->
- {uuid, "#{url}"}
+ {:safe, link} = Phoenix.HTML.Link.link(url, to: url)
+
+ link =
+ link
+ |> IO.iodata_to_binary()
+
+ {uuid, link}
end)
{subs, uuid_text}
@@ -189,7 +195,9 @@ defmodule Pleroma.Formatter do
subs =
subs ++
- Enum.map(mentions, fn {match, %User{ap_id: ap_id}, uuid} ->
+ Enum.map(mentions, fn {match, %User{ap_id: ap_id, info: info}, uuid} ->
+ ap_id = info["source_data"]["url"] || ap_id
+
short_match = String.split(match, "@") |> tl() |> hd()
{uuid, "@#{short_match}"}
end)