diff options
author | lambda <lain@soykaf.club> | 2019-05-01 10:45:32 +0000 |
---|---|---|
committer | lambda <lain@soykaf.club> | 2019-05-01 10:45:32 +0000 |
commit | 0bcdaf378ee41c3845151b59d8820b799532c9a8 (patch) | |
tree | e90070b714d696887ae6280c1572e40559433019 /lib | |
parent | 297596ce4800bed3e6b85721ec384a2a0a0a983f (diff) | |
parent | 85fa2fbce4ee315a15b517fae4bc9b5474d1db5a (diff) | |
download | pleroma-0bcdaf378ee41c3845151b59d8820b799532c9a8.tar.gz |
Merge branch 'bugfix/web-notification-special-char' into 'develop'
fix the web push notification with special char for status created
See merge request pleroma/pleroma!1092
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/html.ex | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/lib/pleroma/html.ex b/lib/pleroma/html.ex index cf6c0ee0a..eb33d12d9 100644 --- a/lib/pleroma/html.ex +++ b/lib/pleroma/html.ex @@ -28,12 +28,18 @@ defmodule Pleroma.HTML do def filter_tags(html), do: filter_tags(html, nil) def strip_tags(html), do: Scrubber.scrub(html, Scrubber.StripTags) - def get_cached_scrubbed_html_for_activity(content, scrubbers, activity, key \\ "") do + def get_cached_scrubbed_html_for_activity( + content, + scrubbers, + activity, + key \\ "", + callback \\ fn x -> x end + ) do key = "#{key}#{generate_scrubber_signature(scrubbers)}|#{activity.id}" Cachex.fetch!(:scrubber_cache, key, fn _key -> object = Pleroma.Object.normalize(activity) - ensure_scrubbed_html(content, scrubbers, object.data["fake"] || false) + ensure_scrubbed_html(content, scrubbers, object.data["fake"] || false, callback) end) end @@ -42,16 +48,27 @@ defmodule Pleroma.HTML do content, HtmlSanitizeEx.Scrubber.StripTags, activity, - key + key, + &HtmlEntities.decode/1 ) end def ensure_scrubbed_html( content, scrubbers, - false = _fake + fake, + callback ) do - {:commit, filter_tags(content, scrubbers)} + content = + content + |> filter_tags(scrubbers) + |> callback.() + + if fake do + {:ignore, content} + else + {:commit, content} + end end def ensure_scrubbed_html( |