Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.
TypeScript analyticsaudience-segmentationchartscohort-analysisgoogle-analyticsproduct-analyticsstatisticsuser-journeyweb-analytics
Use safe URI decoding.
Mike Caob3cad83f082b
diff --git a/src/components/hooks/useNavigation.ts b/src/components/hooks/useNavigation.tsindex 0ff7155a2..a2c1167a5 100644--- a/src/components/hooks/useNavigation.ts+++ b/src/components/hooks/useNavigation.ts@@ -1,6 +1,6 @@import { useMemo } from 'react';import { usePathname, useRouter, useSearchParams } from 'next/navigation';-import { buildUrl } from 'next-basics';+import { buildUrl, safeDecodeURIComponent } from 'next-basics';export function useNavigation(): {pathname: string;@@ -16,7 +16,7 @@ export function useNavigation(): {const obj = {};for (const [key, value] of params.entries()) {- obj[key] = decodeURIComponent(value);+ obj[key] = safeDecodeURIComponent(value);}return obj;diff --git a/src/components/metrics/Legend.tsx b/src/components/metrics/Legend.tsxindex 5fbee827a..c7ef1022b 100644--- a/src/components/metrics/Legend.tsx+++ b/src/components/metrics/Legend.tsx@@ -1,4 +1,5 @@import { StatusLight } from 'react-basics';+import { safeDecodeURIComponent } from 'next-basics';import { colord } from 'colord';import classNames from 'classnames';import { LegendItem } from 'chart.js/auto';@@ -31,7 +32,7 @@ export function Legend({onClick={() => onClick(item)}><StatusLight color={color.alpha(color.alpha() + 0.2).toHex()}>- <span className={locale}>{text}</span>+ <span className={locale}>{safeDecodeURIComponent(text)}</span></StatusLight></div>);diff --git a/src/queries/analytics/reports/getUTM.ts b/src/queries/analytics/reports/getUTM.tsindex c7d393524..289136c2c 100644--- a/src/queries/analytics/reports/getUTM.ts+++ b/src/queries/analytics/reports/getUTM.ts@@ -1,6 +1,7 @@import clickhouse from 'lib/clickhouse';import { CLICKHOUSE, PRISMA, runQuery } from 'lib/db';import prisma from 'lib/prisma';+import { safeDecodeURIComponent } from 'next-basics';export async function getUTM(...args: [@@ -99,7 +100,7 @@ function parseParameters(data: any[]) {for (const [key, value] of searchParams) {if (key.match(/^utm_(\w+)$/)) {- const name = decodeURIComponent(value);+ const name = safeDecodeURIComponent(value);if (!obj[key]) {obj[key] = { [name]: +num };} else if (!obj[key][name]) {