X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fweb%2Fpreload.ex;h=e554965a26a12f42498ca952103f1835db85fabf;hb=9a320ba8149a3efae1235b3b68dbf1bbad423e0d;hp=90e4544686435b1cd6472008aa90d552e5bbd0aa;hpb=26f710b9e36d286ee34dd679fdaf99e39d8c0bf2;p=akkoma diff --git a/lib/pleroma/web/preload.ex b/lib/pleroma/web/preload.ex index 90e454468..e554965a2 100644 --- a/lib/pleroma/web/preload.ex +++ b/lib/pleroma/web/preload.ex @@ -1,12 +1,11 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2020 Pleroma Authors +# Copyright © 2017-2021 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.Preload do alias Phoenix.HTML - require Logger - def build_tags(_conn, params) do + def build_tags(%{assigns: %{csp_nonce: nonce}} = conn, params) do preload_data = Enum.reduce(Pleroma.Config.get([__MODULE__, :providers], []), %{}, fn parser, acc -> terms = @@ -21,16 +20,17 @@ defmodule Pleroma.Web.Preload do rendered_html = preload_data |> Jason.encode!() - |> build_script_tag() + |> build_script_tag(nonce) |> HTML.safe_to_string() rendered_html end - def build_script_tag(content) do + def build_script_tag(content, nonce) do HTML.Tag.content_tag(:script, HTML.raw(content), id: "initial-results", - type: "application/json" + type: "application/json", + nonce: nonce ) end end