Merge branch 'fork' into backend-new
This commit is contained in:
commit
14938d75f1
2 changed files with 15 additions and 1 deletions
|
@ -33,6 +33,7 @@ def translate(text, source_language, target_language) do
|
||||||
{:error, :not_found}
|
{:error, :not_found}
|
||||||
else
|
else
|
||||||
provider.translate(text, source_language, target_language)
|
provider.translate(text, source_language, target_language)
|
||||||
|
|> scrub_html()
|
||||||
end
|
end
|
||||||
|
|
||||||
store_result(result, cache_key)
|
store_result(result, cache_key)
|
||||||
|
@ -112,4 +113,15 @@ defp store_result({:ok, result}, cache_key) do
|
||||||
defp store_result(_, _), do: nil
|
defp store_result(_, _), do: nil
|
||||||
|
|
||||||
defp content_hash(text), do: :crypto.hash(:sha256, text) |> Base.encode64()
|
defp content_hash(text), do: :crypto.hash(:sha256, text) |> Base.encode64()
|
||||||
|
|
||||||
|
defp scrub_html({:ok, %{content: content} = result}) when is_binary(content) do
|
||||||
|
scrubbers = Pleroma.Config.get([:markup, :scrub_policy])
|
||||||
|
|
||||||
|
content
|
||||||
|
|> Pleroma.HTML.filter_tags(scrubbers)
|
||||||
|
|
||||||
|
{:ok, %{result | content: content}}
|
||||||
|
end
|
||||||
|
|
||||||
|
defp scrub_html(result), do: result
|
||||||
end
|
end
|
||||||
|
|
|
@ -79,7 +79,9 @@ defmodule Pleroma.HTML.Scrubber.Default do
|
||||||
Meta.allow_tag_with_this_attribute_values(:span, "class", [
|
Meta.allow_tag_with_this_attribute_values(:span, "class", [
|
||||||
"h-card",
|
"h-card",
|
||||||
"recipients-inline",
|
"recipients-inline",
|
||||||
"quote-inline"
|
"quote-inline",
|
||||||
|
"invisible",
|
||||||
|
"ellipsis"
|
||||||
])
|
])
|
||||||
|
|
||||||
Meta.allow_tag_with_these_attributes(:span, ["lang"])
|
Meta.allow_tag_with_these_attributes(:span, ["lang"])
|
||||||
|
|
Loading…
Reference in a new issue