Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

escape team name in CRM (#5321)

Cenk Kücüke6f6673dca14
diff --git a/lib/plausible/auth/user_admin.ex b/lib/plausible/auth/user_admin.ex
index 82437178de..c71b5e65f0 100644
--- a/lib/plausible/auth/user_admin.ex
+++ b/lib/plausible/auth/user_admin.ex
@@ -62,7 +62,7 @@ defmodule Plausible.Auth.UserAdmin do
teams
|> Enum.map_join("<br>\n", fn team ->
"""
- <a href="/crm/teams/team/#{team.id}">#{team.name}</a>
+ <a href="/crm/teams/team/#{team.id}">#{html_escape(team.name)}</a>
"""
end)
end
@@ -72,4 +72,10 @@ defmodule Plausible.Auth.UserAdmin do
defp format_date(date) do
Calendar.strftime(date, "%b %-d, %Y")
end
+
+ def html_escape(string) do
+ string
+ |> Phoenix.HTML.html_escape()
+ |> Phoenix.HTML.safe_to_string()
+ end
end
diff --git a/lib/plausible_web/controllers/admin_controller.ex b/lib/plausible_web/controllers/admin_controller.ex
index 01b353ac66..2ae12033ef 100644
--- a/lib/plausible_web/controllers/admin_controller.ex
+++ b/lib/plausible_web/controllers/admin_controller.ex
@@ -99,10 +99,10 @@ defmodule PlausibleWeb.AdminController do
select:
fragment(
"""
- case when ? = false then
- string_agg(concat(?, ' (', ?, ')'), ',')
- else
- concat(?, ' [', string_agg(concat(?, ' (', ?, ')'), ','), ']')
+ case when ? = false then
+ string_agg(concat(?, ' (', ?, ')'), ',')
+ else
+ concat(?, ' [', string_agg(concat(?, ' (', ?, ')'), ','), ']')
end
""",
t.setup_complete,
@@ -155,9 +155,9 @@ defmodule PlausibleWeb.AdminController do
select: [
fragment(
"""
- case when ? = false then
+ case when ? = false then
concat(string_agg(concat(?, ' (', ?, ')'), ','), ' - ', ?)
- else
+ else
concat(concat(?, ' [', string_agg(concat(?, ' (', ?, ')'), ','), ']'), ' - ', ?)
end
""",
@@ -187,7 +187,7 @@ defmodule PlausibleWeb.AdminController do
defp usage_and_limits_html(team, usage, limits, embed?) do
content = """
<ul>
- <li>Team: <b>#{team.name}</b></li>
+ <li>Team: <b>#{html_escape(team.name)}</b></li>
<li>Subscription plan: #{Teams.TeamAdmin.subscription_plan(team)}</li>
<li>Subscription status: #{Teams.TeamAdmin.subscription_status(team)}</li>
<li>Grace period: #{Teams.TeamAdmin.grace_period_status(team)}</li>