mirror of
https://github.com/umami-software/umami.git
synced 2026-02-11 08:07:12 +01:00
Check the hostname value for legality to eliminate dirty data
Check the hostname value for legality to eliminate dirty data
This commit is contained in:
parent
7bfbe26485
commit
35cf149876
1 changed files with 7 additions and 0 deletions
|
|
@ -30,6 +30,13 @@ export async function findSession(req: NextApiRequestCollect) {
|
||||||
// Verify payload
|
// Verify payload
|
||||||
const { website: websiteId, hostname, screen, language } = payload;
|
const { website: websiteId, hostname, screen, language } = payload;
|
||||||
|
|
||||||
|
|
||||||
|
// Check the hostname value for legality to eliminate dirty data
|
||||||
|
const validHostnameRegex = /^[\w-.]+$/;
|
||||||
|
if (!validHostnameRegex.test(hostname)) {
|
||||||
|
throw new Error('Invalid hostname.');
|
||||||
|
}
|
||||||
|
|
||||||
if (!validate(websiteId)) {
|
if (!validate(websiteId)) {
|
||||||
throw new Error('Invalid website ID.');
|
throw new Error('Invalid website ID.');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue