mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-07 01:09:54 +08:00
fix: incomplete URL substring sanitization (#4309)
Co-authored-by: Peng Xiao <pengxiao@outlook.com>
This commit is contained in:
@@ -179,7 +179,7 @@ export class NextAuthController {
|
|||||||
});
|
});
|
||||||
if (
|
if (
|
||||||
!req.headers?.referer ||
|
!req.headers?.referer ||
|
||||||
req.headers.referer.startsWith('https://accounts.google.com')
|
checkUrlOrigin(req.headers.referer, 'https://accounts.google.com')
|
||||||
) {
|
) {
|
||||||
res.redirect('https://community.affine.pro/c/insider-general/');
|
res.redirect('https://community.affine.pro/c/insider-general/');
|
||||||
} else {
|
} else {
|
||||||
@@ -307,3 +307,11 @@ export class NextAuthController {
|
|||||||
throw new BadRequestException(`User not found`);
|
throw new BadRequestException(`User not found`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const checkUrlOrigin = (url: string, origin: string) => {
|
||||||
|
try {
|
||||||
|
return new URL(url).origin === origin;
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user