mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 09:38:19 +08:00
core: handle invalid referer url
This commit is contained in:
1 parent
f305cbfc60
commit
16992e057d
1 file changed
+6
-2
@@ -189,8 +189,12 @@ export class Handler extends HandlerCommon {
|
||||
|
||||
async init() {
|
||||
if (this.request.method === 'post' && this.request.headers.referer && !this.context.cors && !this.allowCors) {
|
||||
const host = new URL(this.request.headers.referer).host;
|
||||
if (host !== this.request.host) this.context.pendingError = new CsrfTokenError(host);
|
||||
try {
|
||||
const host = new URL(this.request.headers.referer).host;
|
||||
if (host !== this.request.host) this.context.pendingError = new CsrfTokenError(host);
|
||||
} catch (e) {
|
||||
this.context.pendingError = new CsrfTokenError();
|
||||
}
|
||||
}
|
||||
if (!argv.options.benchmark) await this.limitRate('global', 5, 100);
|
||||
if (!this.noCheckPermView && !this.user.hasPriv(PRIV.PRIV_VIEW_ALL_DOMAIN)) this.checkPerm(PERM.PERM_VIEW);
|
||||
|
||||
Reference in new issue
Block a user