projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
kill @httpoison
[akkoma]
/
lib
/
pleroma
/
html.ex
diff --git
a/lib/pleroma/html.ex
b/lib/pleroma/html.ex
index 2c701adb528dc7c492faae60dd9a4f94e14c5017..d1da746de0c781d6bd08a386641cad36492c9fd4 100644
(file)
--- a/
lib/pleroma/html.ex
+++ b/
lib/pleroma/html.ex
@@
-28,11
+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 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 ->
key = "#{key}#{generate_scrubber_signature(scrubbers)}|#{activity.id}"
Cachex.fetch!(:scrubber_cache, key, fn _key ->
- ensure_scrubbed_html(content, scrubbers, activity.data["object"]["fake"] || false)
+ object = Pleroma.Object.normalize(activity)
+ ensure_scrubbed_html(content, scrubbers, object.data["fake"] || false, callback)
end)
end
end)
end
@@
-41,24
+48,27
@@
defmodule Pleroma.HTML do
content,
HtmlSanitizeEx.Scrubber.StripTags,
activity,
content,
HtmlSanitizeEx.Scrubber.StripTags,
activity,
- key
+ key,
+ &HtmlEntities.decode/1
)
end
def ensure_scrubbed_html(
content,
scrubbers,
)
end
def ensure_scrubbed_html(
content,
scrubbers,
- false = _fake
- ) do
- {:commit, filter_tags(content, scrubbers)}
- end
-
- def ensure_scrubbed_html(
- content,
- scrubbers,
- true = _fake
+ fake,
+ callback
) do
) do
- {:ignore, filter_tags(content, scrubbers)}
+ content =
+ content
+ |> filter_tags(scrubbers)
+ |> callback.()
+
+ if fake do
+ {:ignore, content}
+ else
+ {:commit, content}
+ end
end
defp generate_scrubber_signature(scrubber) when is_atom(scrubber) do
end
defp generate_scrubber_signature(scrubber) when is_atom(scrubber) do
@@
-141,6
+151,7
@@
defmodule Pleroma.HTML.Scrubber.TwitterText do
Meta.allow_tag_with_these_attributes("img", [
"width",
"height",
Meta.allow_tag_with_these_attributes("img", [
"width",
"height",
+ "class",
"title",
"alt"
])
"title",
"alt"
])
@@
-211,6
+222,7
@@
defmodule Pleroma.HTML.Scrubber.Default do
Meta.allow_tag_with_these_attributes("img", [
"width",
"height",
Meta.allow_tag_with_these_attributes("img", [
"width",
"height",
+ "class",
"title",
"alt"
])
"title",
"alt"
])