From 90e39d22d2e94fa348c5506a25aec4fe8fd34f04 Mon Sep 17 00:00:00 2001 From: syuilo <4439005+syuilo@users.noreply.github.com> Date: Sat, 24 May 2025 13:55:34 +0900 Subject: [PATCH 01/10] =?UTF-8?q?fix(backend):=20unallowedFileType?= =?UTF-8?q?=E3=82=A8=E3=83=A9=E3=83=BC=E3=81=8C=E3=83=8F=E3=83=B3=E3=83=89?= =?UTF-8?q?=E3=83=AA=E3=83=B3=E3=82=B0=E3=81=95=E3=82=8C=E3=81=A6=E3=81=84?= =?UTF-8?q?=E3=81=AA=E3=81=84=E5=95=8F=E9=A1=8C=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/src/server/api/endpoints/drive/files/create.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/backend/src/server/api/endpoints/drive/files/create.ts b/packages/backend/src/server/api/endpoints/drive/files/create.ts index 11c255a361..7d5c0ccd4d 100644 --- a/packages/backend/src/server/api/endpoints/drive/files/create.ts +++ b/packages/backend/src/server/api/endpoints/drive/files/create.ts @@ -63,6 +63,12 @@ export const meta = { id: 'b9d8c348-33f0-4673-b9a9-5d4da058977a', httpStatusCode: 413, }, + + unallowedFileType: { + message: 'Cannot upload the file because it is an unallowed file type.', + code: 'UNALLOWED_FILE_TYPE', + id: '4becd248-7f2c-48c4-a9f0-75edc4f9a1ea', + }, }, } as const; @@ -123,6 +129,7 @@ export default class extends Endpoint { // eslint- if (err.id === '282f77bf-5816-4f72-9264-aa14d8261a21') throw new ApiError(meta.errors.inappropriate); if (err.id === 'c6244ed2-a39a-4e1c-bf93-f0fbd7764fa6') throw new ApiError(meta.errors.noFreeSpace); if (err.id === 'f9e4e5f3-4df4-40b5-b400-f236945f7073') throw new ApiError(meta.errors.maxFileSizeExceeded); + if (err.id === 'bd71c601-f9b0-4808-9137-a330647ced9b') throw new ApiError(meta.errors.unallowedFileType); } throw new ApiError(); } finally { From 64791a716088c30cf94c3334b203162ab03401fd Mon Sep 17 00:00:00 2001 From: syuilo <4439005+syuilo@users.noreply.github.com> Date: Sat, 24 May 2025 13:59:26 +0900 Subject: [PATCH 02/10] =?UTF-8?q?fix(frontend):=20=E3=83=A6=E3=83=BC?= =?UTF-8?q?=E3=82=B6=E3=81=AB=E8=A1=A8=E7=A4=BA=E3=81=95=E3=82=8C=E3=82=8B?= =?UTF-8?q?=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E7=A8=AE=E5=88=A5=E3=81=A8?= =?UTF-8?q?=E3=80=81=E5=AE=9F=E9=9A=9B=E3=81=AE=E3=83=95=E3=82=A1=E3=82=A4?= =?UTF-8?q?=E3=83=AB=E7=A8=AE=E5=88=A5=E3=81=8C=E7=95=B0=E3=81=AA=E3=82=8A?= =?UTF-8?q?=E3=80=81=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E3=82=92=E3=82=A2?= =?UTF-8?q?=E3=83=83=E3=83=97=E3=83=AD=E3=83=BC=E3=83=89=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=81=93=E3=81=A8=E3=81=AB=E5=A4=B1=E6=95=97=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=81=93=E3=81=A8=E3=81=8C=E3=81=82=E3=82=8B=E5=95=8F=E9=A1=8C?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix #16091 --- locales/index.d.ts | 4 +++ locales/ja-JP.yml | 1 + .../src/components/MkUploaderDialog.vue | 5 +++- .../frontend/src/pages/admin/roles.editor.vue | 5 +++- packages/frontend/src/pages/admin/roles.vue | 4 +++ packages/frontend/src/utility/drive.ts | 30 ++++++++++--------- 6 files changed, 33 insertions(+), 16 deletions(-) diff --git a/locales/index.d.ts b/locales/index.d.ts index b3f5ff4938..b6b69f3ebe 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -7753,6 +7753,10 @@ export interface Locale extends ILocale { * MIMEタイプを指定します。改行で区切って複数指定できるほか、アスタリスク(*)でワイルドカード指定できます。(例: image/*) */ "uploadableFileTypes_caption": string; + /** + * ファイルによっては種別を判定できないことがあります。そのようなファイルを許可する場合は {x} を指定に追加してください。 + */ + "uploadableFileTypes_caption2": ParameterizedString<"x">; }; "_condition": { /** diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 44e6af61c7..a4081b1bf9 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -2007,6 +2007,7 @@ _role: chatAvailability: "チャットを許可" uploadableFileTypes: "アップロード可能なファイル種別" uploadableFileTypes_caption: "MIMEタイプを指定します。改行で区切って複数指定できるほか、アスタリスク(*)でワイルドカード指定できます。(例: image/*)" + uploadableFileTypes_caption2: "ファイルによっては種別を判定できないことがあります。そのようなファイルを許可する場合は {x} を指定に追加してください。" _condition: roleAssignedTo: "マニュアルロールにアサイン済み" isLocal: "ローカルユーザー" diff --git a/packages/frontend/src/components/MkUploaderDialog.vue b/packages/frontend/src/components/MkUploaderDialog.vue index 4c928c7f6a..3f5f0776a8 100644 --- a/packages/frontend/src/components/MkUploaderDialog.vue +++ b/packages/frontend/src/components/MkUploaderDialog.vue @@ -73,7 +73,10 @@ SPDX-License-Identifier: AGPL-3.0-only
{{ i18n.tsx._uploader.maxFileSizeIsX({ x: $i.policies.maxFileSizeMb + 'MB' }) }}
-
{{ i18n.ts._uploader.allowedTypes }}: {{ $i.policies.uploadableFileTypes.join(', ') }}
+ + + + diff --git a/packages/frontend/src/pages/admin/roles.editor.vue b/packages/frontend/src/pages/admin/roles.editor.vue index 5da969b835..24c3160fdd 100644 --- a/packages/frontend/src/pages/admin/roles.editor.vue +++ b/packages/frontend/src/pages/admin/roles.editor.vue @@ -418,7 +418,10 @@ SPDX-License-Identifier: AGPL-3.0-only - + diff --git a/packages/frontend/src/pages/admin/roles.vue b/packages/frontend/src/pages/admin/roles.vue index c70ae12851..ef6e25685d 100644 --- a/packages/frontend/src/pages/admin/roles.vue +++ b/packages/frontend/src/pages/admin/roles.vue @@ -150,6 +150,10 @@ SPDX-License-Identifier: AGPL-3.0-only + diff --git a/packages/frontend/src/utility/drive.ts b/packages/frontend/src/utility/drive.ts index de473c9b11..f171a4d14d 100644 --- a/packages/frontend/src/utility/drive.ts +++ b/packages/frontend/src/utility/drive.ts @@ -39,20 +39,22 @@ export function uploadFile(file: File | Blob, options: { const filePromise = new Promise((resolve, reject) => { if ($i == null) return reject(); - const allowedMimeTypes = $i.policies.uploadableFileTypes; - const isAllowedMimeType = allowedMimeTypes.some(mimeType => { - if (mimeType === '*' || mimeType === '*/*') return true; - if (mimeType.endsWith('/*')) return file.type.startsWith(mimeType.slice(0, -1)); - return file.type === mimeType; - }); - if (!isAllowedMimeType) { - os.alert({ - type: 'error', - title: i18n.ts.failedToUpload, - text: i18n.ts.cannotUploadBecauseUnallowedFileType, - }); - return reject(); - } + // こっち側で検出するMIME typeとサーバーで検出するMIME typeは異なる場合があるため、こっち側ではやらないことにする + // https://github.com/misskey-dev/misskey/issues/16091 + //const allowedMimeTypes = $i.policies.uploadableFileTypes; + //const isAllowedMimeType = allowedMimeTypes.some(mimeType => { + // if (mimeType === '*' || mimeType === '*/*') return true; + // if (mimeType.endsWith('/*')) return file.type.startsWith(mimeType.slice(0, -1)); + // return file.type === mimeType; + //}); + //if (!isAllowedMimeType) { + // os.alert({ + // type: 'error', + // title: i18n.ts.failedToUpload, + // text: i18n.ts.cannotUploadBecauseUnallowedFileType, + // }); + // return reject(); + //} if ((file.size > instance.maxFileSize) || (file.size > ($i.policies.maxFileSizeMb * 1024 * 1024))) { os.alert({ From 836ed98c548381a94562af3234f4fd0ea7dbe196 Mon Sep 17 00:00:00 2001 From: syuilo <4439005+syuilo@users.noreply.github.com> Date: Sat, 24 May 2025 14:06:54 +0900 Subject: [PATCH 03/10] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8533a4d393..440e2e21e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ - デフォルト値は「ローカルのコンテンツだけ公開」になっています - Feat: ロールでアップロード可能なファイル種別を設定可能になりました - デフォルトは**テキスト、JSON、画像、動画、音声ファイル**になっています。zipなど、その他の種別のファイルは含まれていないため、必要に応じて設定を変更してください。 + - 場合によってはファイル種別を正しく検出できないことがあります(特にテキストフォーマット)。その場合、ファイル種別は application/octet-stream と見做されます。 + - したがって、それらの種別不明ファイルを許可したい場合は application/octet-stream を指定に追加してください。 - Enhance: UIのアイコンデータの読み込みを軽量化 ### Client From 4fcb80bcf22f044193856e5394bebaf2c3a9af96 Mon Sep 17 00:00:00 2001 From: syuilo <4439005+syuilo@users.noreply.github.com> Date: Sat, 24 May 2025 14:28:49 +0900 Subject: [PATCH 04/10] =?UTF-8?q?enhance(backend):=20=E3=83=95=E3=82=A1?= =?UTF-8?q?=E3=82=A4=E3=83=AB=E7=A8=AE=E5=88=A5=E3=81=8C=E5=88=A4=E5=AE=9A?= =?UTF-8?q?=E3=81=A7=E3=81=8D=E3=81=AA=E3=81=84=E5=A0=B4=E5=90=88=E3=80=81?= =?UTF-8?q?=E6=8B=A1=E5=BC=B5=E5=AD=90=E3=82=92=E5=8F=82=E7=85=A7=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/backend/src/core/DriveService.ts | 11 ++++--- packages/backend/src/core/FileInfoService.ts | 33 ++++++++++++++++---- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/packages/backend/src/core/DriveService.ts b/packages/backend/src/core/DriveService.ts index 0c7c06d92f..54d2f26538 100644 --- a/packages/backend/src/core/DriveService.ts +++ b/packages/backend/src/core/DriveService.ts @@ -469,13 +469,14 @@ export class DriveService { if (user && this.meta.sensitiveMediaDetection === 'remote' && this.userEntityService.isLocalUser(user)) skipNsfwCheck = true; const info = await this.fileInfoService.getFileInfo(path, { + fileName: name, skipSensitiveDetection: skipNsfwCheck, sensitiveThreshold: // 感度が高いほどしきい値は低くすることになる - this.meta.sensitiveMediaDetectionSensitivity === 'veryHigh' ? 0.1 : - this.meta.sensitiveMediaDetectionSensitivity === 'high' ? 0.3 : - this.meta.sensitiveMediaDetectionSensitivity === 'low' ? 0.7 : - this.meta.sensitiveMediaDetectionSensitivity === 'veryLow' ? 0.9 : - 0.5, + this.meta.sensitiveMediaDetectionSensitivity === 'veryHigh' ? 0.1 : + this.meta.sensitiveMediaDetectionSensitivity === 'high' ? 0.3 : + this.meta.sensitiveMediaDetectionSensitivity === 'low' ? 0.7 : + this.meta.sensitiveMediaDetectionSensitivity === 'veryLow' ? 0.9 : + 0.5, sensitiveThresholdForPorn: 0.75, enableSensitiveMediaDetectionForVideos: this.meta.enableSensitiveMediaDetectionForVideos, }); diff --git a/packages/backend/src/core/FileInfoService.ts b/packages/backend/src/core/FileInfoService.ts index a295e81920..6250d4d3a1 100644 --- a/packages/backend/src/core/FileInfoService.ts +++ b/packages/backend/src/core/FileInfoService.ts @@ -64,6 +64,7 @@ export class FileInfoService { */ @bindThis public async getFileInfo(path: string, opts: { + fileName?: string | null; skipSensitiveDetection: boolean; sensitiveThreshold?: number; sensitiveThresholdForPorn?: number; @@ -76,6 +77,26 @@ export class FileInfoService { let type = await this.detectType(path); + if (type.mime === TYPE_OCTET_STREAM.mime && opts.fileName != null) { + const ext = opts.fileName.split('.').pop(); + if (ext === 'txt') { + type = { + mime: 'text/plain', + ext: 'txt', + }; + } else if (ext === 'csv') { + type = { + mime: 'text/csv', + ext: 'csv', + }; + } else if (ext === 'json') { + type = { + mime: 'application/json', + ext: 'json', + }; + } + } + // image dimensions let width: number | undefined; let height: number | undefined; @@ -438,12 +459,12 @@ export class FileInfoService { */ @bindThis private async detectImageSize(path: string): Promise<{ - width: number; - height: number; - wUnits: string; - hUnits: string; - orientation?: number; -}> { + width: number; + height: number; + wUnits: string; + hUnits: string; + orientation?: number; + }> { const readable = fs.createReadStream(path); const imageSize = await probeImageSize(readable); readable.destroy(); From fe1b2b00f5fb162ae03d9f304f5e5a54a09d4ff2 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 24 May 2025 05:32:52 +0000 Subject: [PATCH 05/10] Bump version to 2025.5.1-beta.1 --- package.json | 2 +- packages/misskey-js/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 50c2542ffb..16692f5f7e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "misskey", - "version": "2025.5.1-beta.0", + "version": "2025.5.1-beta.1", "codename": "nasubi", "repository": { "type": "git", diff --git a/packages/misskey-js/package.json b/packages/misskey-js/package.json index d6a98ff2b3..27c489e959 100644 --- a/packages/misskey-js/package.json +++ b/packages/misskey-js/package.json @@ -1,7 +1,7 @@ { "type": "module", "name": "misskey-js", - "version": "2025.5.1-beta.0", + "version": "2025.5.1-beta.1", "description": "Misskey SDK for JavaScript", "license": "MIT", "main": "./built/index.js", From 02041344bdc2ac39c67d9b01e88d65c983059dcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=8B=E3=81=A3=E3=81=93=E3=81=8B=E3=82=8A?= <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Sat, 24 May 2025 18:31:55 +0900 Subject: [PATCH 06/10] =?UTF-8?q?fix(frontend);=20=E3=82=AB=E3=82=B9?= =?UTF-8?q?=E3=82=BF=E3=83=A0=E7=B5=B5=E6=96=87=E5=AD=97=E3=81=AE=E3=83=AA?= =?UTF-8?q?=E3=82=A2=E3=82=AF=E3=82=B7=E3=83=A7=E3=83=B3=E3=81=8C=E4=BA=8C?= =?UTF-8?q?=E9=87=8D=E3=81=A7=E8=A1=A8=E7=A4=BA=E3=81=95=E3=82=8C=E3=82=8B?= =?UTF-8?q?=E3=81=93=E3=81=A8=E3=81=8C=E3=81=82=E3=82=8B=E5=95=8F=E9=A1=8C?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3=20(#16092)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(frontend): カスタム絵文字のリアクションが二重で表示されることがある問題を修正 * fix: improve event locking mechanism * fix: remove unused console log * fix: unused import * fix: その場で書き換えることで再レンダリングを最小限に抑える(かも) * refactor: reactive note data を composable内で生成するように --- packages/frontend/src/components/MkNote.vue | 23 ++---- .../src/components/MkNoteDetailed.vue | 17 +--- .../src/composables/use-note-capture.ts | 79 +++++++++++++------ 3 files changed, 65 insertions(+), 54 deletions(-) diff --git a/packages/frontend/src/components/MkNote.vue b/packages/frontend/src/components/MkNote.vue index ee8a470b0e..4a78d00665 100644 --- a/packages/frontend/src/components/MkNote.vue +++ b/packages/frontend/src/components/MkNote.vue @@ -193,7 +193,7 @@ SPDX-License-Identifier: AGPL-3.0-only