Skip to content

Commit

Permalink
Revert "ユーザー名がUnicode制御文字とスペースのみで構成される場合はnullに"
Browse files Browse the repository at this point in the history
This reverts commit 6c752a6.
  • Loading branch information
kakkokari-gtyih committed Jul 2, 2024
1 parent 6c752a6 commit 38eb06f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 17 deletions.
10 changes: 1 addition & 9 deletions packages/backend/src/server/api/endpoints/i/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,6 @@ 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>;

Expand All @@ -264,13 +262,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
updates.name = null;
} else {
const trimmedName = ps.name.trim();
if (trimmedName === '') {
updates.name = null;
} else if (onlyControlCharsAndSpaceRegex.test(trimmedName)) {
updates.name = null;
} else {
updates.name = trimmedName;
}
updates.name = trimmedName === '' ? null : trimmedName;
}
}
if (ps.description !== undefined) profileUpdates.description = ps.description;
Expand Down
8 changes: 0 additions & 8 deletions packages/backend/test/e2e/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,6 @@ describe('Endpoints', () => {
assert.strictEqual(res.body.name, 'あ い う');
});

test('名前にUnicode制御文字とスペースしか含まない場合はnullになる', async () => {
const res = await api('i/update', {
name: ' \u202e ',
}, alice);
assert.strictEqual(res.status, 200);
assert.strictEqual(res.body.name, null);
});

test('誕生日の設定を削除できる', async () => {
await api('i/update', {
birthday: '2000-09-07',
Expand Down

0 comments on commit 38eb06f

Please sign in to comment.