mirror of
https://github.com/kremalicious/umami.git
synced 2025-01-22 07:49:29 +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
@ -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…
Reference in New Issue
Block a user