インスタンスURLのバリデーション
This commit is contained in:
parent
9d7f78856d
commit
9cc696f87a
6 changed files with 43 additions and 11 deletions
|
@ -29,7 +29,17 @@ router.get('/login', async ctx => {
|
|||
return;
|
||||
}
|
||||
|
||||
const meta = await api<{ name: string, uri: string, version: string, features: Record<string, boolean | undefined> }>(host, 'meta', {});
|
||||
// http://, https://を潰す
|
||||
host = host.trim().replace(/^https?:\/\//g, '').replace(/\/+/g, '');
|
||||
|
||||
const meta = await api<{ name: string, uri: string, version: string, features: Record<string, boolean | undefined> }>(host, 'meta', {}).catch(async e => {
|
||||
if (!(e instanceof Error && e.name === 'Error')) throw e;
|
||||
await die(ctx, 'hostNotFound');
|
||||
});
|
||||
|
||||
// NOTE: catchが呼ばれた場合はvoidとなるためundefinedのはず
|
||||
if (typeof meta === 'undefined') return;
|
||||
|
||||
if (typeof meta !== 'object') {
|
||||
await die(ctx, 'other');
|
||||
return;
|
||||
|
@ -40,9 +50,6 @@ router.get('/login', async ctx => {
|
|||
return;
|
||||
}
|
||||
|
||||
// ホスト名の正規化
|
||||
host = meta.uri.replace(/^https?:\/\//, '');
|
||||
|
||||
const { name, permission, description } = misskeyAppInfo;
|
||||
|
||||
if (meta.features.miauth) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue