ユーザー名がUnicode制御文字とスペースのみで構成される場合はnullに
This commit is contained in:
@@ -252,6 +252,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||
const user = await this.usersRepository.findOneByOrFail({ id: _user.id }) as MiLocalUser;
|
||||
const isSecure = token == null;
|
||||
|
||||
const onlyControlCharsAndSpaceRegex = /^[\u0000-\u001F\u007F-\u009F\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069\s]+$/;
|
||||
|
||||
const updates = {} as Partial<MiUser>;
|
||||
const profileUpdates = {} as Partial<MiUserProfile>;
|
||||
|
||||
@@ -262,7 +264,13 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||
updates.name = null;
|
||||
} else {
|
||||
const trimmedName = ps.name.trim();
|
||||
updates.name = trimmedName === '' ? null : trimmedName;
|
||||
if (trimmedName === '') {
|
||||
updates.name = null;
|
||||
} else if (onlyControlCharsAndSpaceRegex.test(trimmedName)) {
|
||||
updates.name = null;
|
||||
} else {
|
||||
updates.name = trimmedName;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ps.description !== undefined) profileUpdates.description = ps.description;
|
||||
|
Reference in New Issue
Block a user