aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/formatter.ex
diff options
context:
space:
mode:
authorraeno <just.raeno@gmail.com>2018-12-19 22:39:44 +0400
committerraeno <just.raeno@gmail.com>2018-12-19 22:39:44 +0400
commit7fb37804313339f9a2215aea27ece42e8ec31312 (patch)
treeb7438e9ecd2f4f90e171c16bacbe538cb1ef6e4e /lib/pleroma/formatter.ex
parenta3003364598b42849e384a216948dad810481f51 (diff)
parentf98ee9402fcafff362ab2446f386214d7a5c41c7 (diff)
downloadpleroma-7fb37804313339f9a2215aea27ece42e8ec31312.tar.gz
Merge branch 'develop' into oembed_provider
Diffstat (limited to 'lib/pleroma/formatter.ex')
-rw-r--r--lib/pleroma/formatter.ex6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/pleroma/formatter.ex b/lib/pleroma/formatter.ex
index 8024d97c2..74626bbc1 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 =