MastodonAPI.StatusView: Do not use site_name
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Fri, 14 Feb 2020 23:35:46 +0000 (00:35 +0100)
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Fri, 14 Feb 2020 23:36:09 +0000 (00:36 +0100)
site_name allow to spoof the origin of the domain and so hacks like:

<!-- served on https://hacktivis.me/tmp/joinmastodon.org.html -->
<meta property="og:image" content="https://hacktivis.me/datalove/img/meme/pleroma/mastodon%2C%20forbidden%20amuse%20yourself.jpeg" />
<meta property="og:title" content="Mastodon: Forbidden Amuse Yourself" />
<meta property="og:site_name" content="joinmastodon.org" />
<meta http-equiv="refresh" content="0; url=http://joinmastodon.org/">

lib/pleroma/web/mastodon_api/views/status_view.ex
test/web/mastodon_api/views/status_view_test.exs

index e1e92034f04b00f985c8784a095a66012aae4826..d4695c1c6cff04c207aca524446554b5a6ed7971 100644 (file)
@@ -321,11 +321,9 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
         nil
       end
 
-    site_name = rich_media[:site_name] || page_url_data.host
-
     %{
       type: "link",
-      provider_name: site_name,
+      provider_name: page_url_data.host,
       provider_url: page_url_data.scheme <> "://" <> page_url_data.host,
       url: page_url,
       image: image_url |> MediaProxy.url(),
index ba58e48e88d37a13ecb46a6524050792f166b2d3..560f8179ffc6d5127aa8da3a5dfd72f250df48b1 100644 (file)
@@ -491,7 +491,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
         title: "Example website"
       }
 
-      %{provider_name: "Example site name"} =
+      %{provider_name: "example.com"} =
         StatusView.render("card.json", %{page_url: page_url, rich_media: card})
     end
 
@@ -506,7 +506,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
         description: "Example description"
       }
 
-      %{provider_name: "Example site name"} =
+      %{provider_name: "example.com"} =
         StatusView.render("card.json", %{page_url: page_url, rich_media: card})
     end
   end