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

+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);
}
}