Skip to content
Snippets Groups Projects
Unverified Commit 618e2ba1 authored by zyoshoka's avatar zyoshoka Committed by GitHub
Browse files

fix(backend): `drive/files/update`におけるファイル名のバリデーションが機能していない問題を修正 (#12923)

* fix(backend): `drive/files/update`におけるファイル名のバリデーションが機能していない問題を修正

* Update CHANGELOG.md

* refactor: `!== undefined` -> `!= null`

* add test
parent 04f9147d
No related branches found
No related tags found
No related merge requests found
......@@ -29,6 +29,7 @@
- Enhance: 連合先のレートリミットに引っかかった際にリトライするようになりました
- Enhance: ActivityPub Deliver queueでBodyを事前処理するように (#12916)
- Enhance: クリップをエクスポートできるように
- Fix: `drive/files/update`でファイル名のバリデーションが機能していない問題を修正
## 2023.12.2
......
......@@ -655,7 +655,7 @@ export class DriveService {
public async updateFile(file: MiDriveFile, values: Partial<MiDriveFile>, updater: MiUser) {
const alwaysMarkNsfw = (await this.roleService.getUserPolicies(file.userId)).alwaysMarkNsfw;
if (values.name && !this.driveFileEntityService.validateFileName(file.name)) {
if (values.name != null && !this.driveFileEntityService.validateFileName(values.name)) {
throw new DriveService.InvalidFileNameError();
}
......
......@@ -710,6 +710,18 @@ describe('Endpoints', () => {
assert.strictEqual(res.status, 400);
});
test('不正なファイル名で怒られる', async () => {
const file = (await uploadFile(alice)).body;
const newName = '';
const res = await api('/drive/files/update', {
fileId: file.id,
name: newName,
}, alice);
assert.strictEqual(res.status, 400);
});
test('間違ったIDで怒られる', async () => {
const res = await api('/drive/files/update', {
fileId: 'kyoppie',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment