core: fix filter

This commit is contained in:
undefined committed 2021-05-07 08:30:43 +08:00
1 parent fc98c61f7b
commit 229869bc5c
2 files changed
+4 -4

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "2.24.19",
"version": "2.24.20",
"bin": "bin/hydrooj.js",
"main": "dist/loader.js",
"typings": "dist/loader.d.ts",
+3 -3
View File
@@ -520,9 +520,9 @@ export class Handler extends HandlerCommon {
text: global.Hydro.lib[key].text,
}));
if (!this.noCheckPermView) this.checkPerm(PERM.PERM_VIEW);
if (this.request.method === 'POST' && this.request.headers.referer) {
const hostname = new URL(this.request.headers.referer).hostname;
if (hostname !== this.request.hostname) throw new CsrfTokenError(hostname);
if (this.request.method === 'post' && this.request.headers.referer !== '/') {
const host = new URL(this.request.headers.referer).host;
if (host !== this.request.host) throw new CsrfTokenError(host);
}
}