Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
Escape domain when creating URL for favicon (#2942)
Harry Vangberg34a6b984c7c8
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex f3b37ff6e9..0f56d780f9 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -24,6 +24,7 @@ All notable changes to this project will be documented in this file.- Add error message in case a transfer to an invited (but not joined) user is requested plausible/analytics#2651- Fix bug with [showing property breakdown with a prop filter](https://github.com/plausible/analytics/issues/1789)- Fix bug when combining goal and prop filters plausible/analytics#2654+- Fix broken favicons when domain includes a slash### Changed- Treat page filter as entry page filter for `bounce_rate`diff --git a/lib/plausible_web/plugs/favicon.ex b/lib/plausible_web/plugs/favicon.exindex 3ce3bf60da..e8dc9a5e20 100644--- a/lib/plausible_web/plugs/favicon.ex+++ b/lib/plausible_web/plugs/favicon.ex@@ -80,11 +80,11 @@ defmodule PlausibleWeb.Favicon do"""def call(conn, favicon_domains: favicon_domains) do- case conn.path_info do- ["favicon", "sources", "placeholder"] ->+ case conn.request_path do+ "/favicon/sources/placeholder" ->send_placeholder(conn)- ["favicon", "sources", source] ->+ "/favicon/sources/" <> source ->clean_source = URI.decode_www_form(source)domain = Map.get(favicon_domains, clean_source, clean_source)diff --git a/test/plausible_web/plugs/favicon_test.exs b/test/plausible_web/plugs/favicon_test.exsindex a62e4232a4..45f93d457d 100644--- a/test/plausible_web/plugs/favicon_test.exs+++ b/test/plausible_web/plugs/favicon_test.exs@@ -38,6 +38,24 @@ defmodule PlausibleWeb.FaviconTest doassert conn.resp_body == "favicon response body"end+ test "requests favicon from DDG when domain contains a forward slash", %{plug_opts: plug_opts} do+ expect(+ Plausible.HTTPClient.Mock,+ :get,+ fn "https://icons.duckduckgo.com/ip3/site.com/subfolder.ico" ->+ {:ok, %Finch.Response{status: 200, body: "favicon response body"}}+ end+ )++ conn =+ conn(:get, "/favicon/sources/site.com/subfolder")+ |> Favicon.call(plug_opts)++ assert conn.halted+ assert conn.status == 200+ assert conn.resp_body == "favicon response body"+ end+test "sets content-disposition and content-security-policy", %{plug_opts: plug_opts} doexpect(Plausible.HTTPClient.Mock,