forked from AkkomaGang/akkoma
Fix HTML escape breaking some links.
This commit is contained in:
parent
afd0ea37f3
commit
bf91e5659f
2 changed files with 11 additions and 2 deletions
|
@ -24,6 +24,15 @@ def parse_mentions(text) do
|
||||||
|> Enum.filter(fn ({_match, user}) -> user end)
|
|> Enum.filter(fn ({_match, user}) -> user end)
|
||||||
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 [
|
@finmoji [
|
||||||
"a_trusted_friend",
|
"a_trusted_friend",
|
||||||
"alandislands",
|
"alandislands",
|
||||||
|
|
|
@ -58,8 +58,8 @@ def add_attachments(text, attachments) do
|
||||||
end
|
end
|
||||||
|
|
||||||
def format_input(text, mentions, _tags) do
|
def format_input(text, mentions, _tags) do
|
||||||
Phoenix.HTML.html_escape(text)
|
text
|
||||||
|> elem(1)
|
|> Formatter.html_escape
|
||||||
|> Formatter.linkify
|
|> Formatter.linkify
|
||||||
|> String.replace("\n", "<br>")
|
|> String.replace("\n", "<br>")
|
||||||
|> add_user_links(mentions)
|
|> add_user_links(mentions)
|
||||||
|
|
Loading…
Reference in a new issue