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
Disallow site creation with insufficient input (#2741)
Adam3417b2dd0eb9
diff --git a/lib/plausible/site.ex b/lib/plausible/site.exindex ca466ce06b..a87af1026a 100644--- a/lib/plausible/site.ex+++ b/lib/plausible/site.ex@@ -43,8 +43,8 @@ defmodule Plausible.Site dodef changeset(site, attrs \\ %{}) dosite|> cast(attrs, [:domain, :timezone])- |> validate_required([:domain, :timezone])|> clean_domain()+ |> validate_required([:domain, :timezone])|> validate_format(:domain, ~r/^[-\.\\\/:\p{L}\d]*$/u,message: "only letters, numbers, slashes and period allowed")diff --git a/test/plausible_web/controllers/site_controller_test.exs b/test/plausible_web/controllers/site_controller_test.exsindex 647b9df834..eee7f47652 100644--- a/test/plausible_web/controllers/site_controller_test.exs+++ b/test/plausible_web/controllers/site_controller_test.exs@@ -108,6 +108,18 @@ defmodule PlausibleWeb.SiteControllerTest doassert Repo.get_by(Plausible.Site, domain: "example.com")end+ test "fails to create the site if only http:// provided", %{conn: conn} do+ conn =+ post(conn, "/sites", %{+ "site" => %{+ "domain" => "http://",+ "timezone" => "Europe/London"+ }+ })++ assert html_response(conn, 200) =~ "can't be blank"+ end+test "starts trial if user does not have trial yet", %{conn: conn, user: user} doPlausible.Auth.User.remove_trial_expiry(user) |> Repo.update!()