Truncate incoming referrer string (#260)

This commit is contained in:
liamwhite 2024-05-18 16:29:27 -04:00 committed by GitHub
parent 65da36369d
commit b235f545f2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -24,7 +24,7 @@ defmodule PhilomenaWeb.UserAttributionPlug do
attributes = [ attributes = [
ip: remote_ip, ip: remote_ip,
fingerprint: fingerprint(conn, conn.path_info), fingerprint: fingerprint(conn, conn.path_info),
referrer: conn.assigns.referrer, referrer: referrer(conn.assigns.referrer),
user: user, user: user,
user_agent: user_agent(conn) user_agent: user_agent(conn)
] ]
@ -47,4 +47,7 @@ defmodule PhilomenaWeb.UserAttributionPlug do
defp fingerprint(conn, _) do defp fingerprint(conn, _) do
conn.cookies["_ses"] conn.cookies["_ses"]
end end
defp referrer(nil), do: nil
defp referrer(r), do: String.slice(r, 0, 255)
end end