Skip to content

armgit / umami

Public Imported from GitHub
0

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.

fix: use safeDecodeURIComponent for location fields in user detection

Exlasobf94c5dc73d3
diff --git a/src/lib/detect.ts b/src/lib/detect.ts
index 8712632ae..2b1fe01d3 100644
--- a/src/lib/detect.ts
+++ b/src/lib/detect.ts
@@ -11,6 +11,7 @@ import {
MOBILE_OS,
MOBILE_SCREEN_WIDTH,
} from './constants';
+import { safeDecodeURIComponent } from '@/lib/url';
const MAXMIND = 'maxmind';
@@ -146,9 +147,9 @@ export async function getClientInfo(request: Request, payload: Record<string, an
const userAgent = payload?.userAgent || request.headers.get('user-agent');
const ip = payload?.ip || getIpAddress(request.headers);
const location = await getLocation(ip, request.headers, !!payload?.ip);
- const country = decodeURIComponent(location?.country || 'UNKNOWN');
- const region = decodeURIComponent(location?.region || 'UNKNOWN');
- const city = decodeURIComponent(location?.city || 'UNKNOWN');
+ const country = safeDecodeURIComponent(location?.country);
+ const region = safeDecodeURIComponent(location?.region);
+ const city = safeDecodeURIComponent(location?.city);
const browser = browserName(userAgent);
const os = detectOS(userAgent) as string;
const device = getDevice(payload?.screen, os);