Player: allow styles on CSP, loop videos
authorhref <href@random.sh>
Tue, 19 Feb 2019 17:56:57 +0000 (18:56 +0100)
committerhref <href@random.sh>
Tue, 19 Feb 2019 17:56:57 +0000 (18:56 +0100)
lib/pleroma/web/metadata/player_view.ex
lib/pleroma/web/metadata/twitter_card.ex
lib/pleroma/web/ostatus/ostatus_controller.ex
lib/pleroma/web/templates/layout/metadata_player.html.eex

index 68b0a3507196da8b0325b21542950e6cb8096168..e9a8cfc8dd24462a66998c5c48fa2fd9895709d7 100644 (file)
@@ -3,10 +3,10 @@ defmodule Pleroma.Web.Metadata.PlayerView do
   import Phoenix.HTML.Tag, only: [content_tag: 3, tag: 2]
 
   def render("player.html", %{"mediaType" => type, "href" => href}) do
-    tag_type =
+    {tag_type, tag_attrs} =
       case type do
-        "audio" <> _ -> :audio
-        "video" <> _ -> :video
+        "audio" <> _ -> {:audio, []}
+        "video" <> _ -> {:video, [loop: true]}
       end
 
     content_tag(
@@ -15,7 +15,7 @@ defmodule Pleroma.Web.Metadata.PlayerView do
         tag(:source, src: href, type: type),
         "Your browser does not support #{type} playback."
       ],
-      controls: true
+      [controls: true] ++ tag_attrs
     )
   end
 end
index e7f5760a9465d731af54b16a4cfe74000f23eaf4..d672b397f8cf9006935c6f41b73af95f8d0a7ba5 100644 (file)
@@ -104,8 +104,8 @@ defmodule Pleroma.Web.Metadata.Providers.TwitterCard do
               [
                 {:meta, [property: "twitter:card", content: "player"], []},
                 {:meta, [property: "twitter:player", content: player_url(id)], []},
-                {:meta, [property: "twitter:player:width", content: "1280"], []},
-                {:meta, [property: "twitter:player:height", content: "720"], []}
+                {:meta, [property: "twitter:player:width", content: "480"], []},
+                {:meta, [property: "twitter:player:height", content: "480"], []}
                 | acc
               ]
 
index 4877e032bf015f1f7b54083ef828a52a525416ba..0490a32d30c8208ce30651a92c82e84b9ecae65c 100644 (file)
@@ -197,7 +197,7 @@ defmodule Pleroma.Web.OStatus.OStatusController do
       |> put_resp_header("x-frame-options", "ALLOW")
       |> put_resp_header(
         "content-security-policy",
-        "default-src 'none'; img-src 'self' data: https:; media-src 'self' https:;"
+        "default-src 'none';style-src 'self' 'unsafe-inline';img-src 'self' data: https:; media-src 'self' https:;"
       )
       |> put_view(Pleroma.Web.Metadata.PlayerView)
       |> render("player.html", url)
index 7a170551564c73912b67198e7c02f56dceac36d1..460f280944a83d7cbbee59b4bd5705dd7f52434b 100644 (file)
@@ -3,10 +3,10 @@
 <body>
 
 <style type="text/css">
-video {
+video, audio {
    width:100%;
    max-width:600px;
-   height:auto;
+   height: auto;
 }
 </style>