diff options
author | rinpatch <rinpatch@sdf.org> | 2018-12-18 21:38:15 +0300 |
---|---|---|
committer | rinpatch <rinpatch@sdf.org> | 2018-12-18 21:38:15 +0300 |
commit | 059dd6f681caf14ee9d288ec14b82132be29ae2c (patch) | |
tree | 1d1481c4e74ffb9e577614a1e05a0ab97a6023fd /lib | |
parent | 8cb9580aec10f0f258f4fbd82065d02b0a82b003 (diff) | |
download | pleroma-059dd6f681caf14ee9d288ec14b82132be29ae2c.tar.gz |
Ignore HTML characters in formatter.ex
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/formatter.ex | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/pleroma/formatter.ex b/lib/pleroma/formatter.ex index 46d0d926a..9401689cb 100644 --- a/lib/pleroma/formatter.ex +++ b/lib/pleroma/formatter.ex @@ -4,12 +4,12 @@ defmodule Pleroma.Formatter do alias Pleroma.HTML alias Pleroma.Emoji - @tag_regex ~r/\#\w+/u + @tag_regex ~r/((?<=[^&])|\A)(\#)(\w+)/u @markdown_characters_regex ~r/(`|\*|_|{|}|[|]|\(|\)|#|\+|-|\.|!)/ def parse_tags(text, data \\ %{}) do Regex.scan(@tag_regex, text) - |> Enum.map(fn ["#" <> tag = full_tag] -> {full_tag, String.downcase(tag)} end) + |> Enum.map(fn ["#" <> tag = full_tag | _] -> {full_tag, String.downcase(tag)} end) |> (fn map -> if data["sensitive"] in [true, "True", "true", "1"], do: [{"#nsfw", "nsfw"}] ++ map, @@ -155,7 +155,7 @@ defmodule Pleroma.Formatter do uuid_text = tags |> Enum.reduce(text, fn {match, _short, uuid}, text -> - String.replace(text, match, uuid) + String.replace(text, ~r/((?<=[^&])|(\A))#{match}/, uuid) end) subs = |