From 3e00ce0d88b5ef6adf7a44de91e43a623b23eef6 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 29 Dec 2021 17:04:13 +0900 Subject: [PATCH 01/13] =?UTF-8?q?fix(server):=20=E3=82=A8=E3=82=AF?= =?UTF-8?q?=E3=82=B9=E3=83=9D=E3=83=BC=E3=83=88=E3=81=97=E3=81=9F=E7=B5=B5?= =?UTF-8?q?=E6=96=87=E5=AD=97=E3=81=AE=E6=8B=A1=E5=BC=B5=E5=AD=90=E3=81=8C?= =?UTF-8?q?false=E3=81=AB=E3=81=AA=E3=82=8B=E3=81=93=E3=81=A8=E3=81=8C?= =?UTF-8?q?=E3=81=82=E3=82=8B=E3=81=AE=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/queue/processors/db/export-custom-emojis.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/queue/processors/db/export-custom-emojis.ts b/packages/backend/src/queue/processors/db/export-custom-emojis.ts index 925b187970..3930b9d6d4 100644 --- a/packages/backend/src/queue/processors/db/export-custom-emojis.ts +++ b/packages/backend/src/queue/processors/db/export-custom-emojis.ts @@ -65,7 +65,8 @@ export async function exportCustomEmojis(job: Bull.Job, done: () => void): Promi for (const emoji of customEmojis) { const exportId = ulid().toLowerCase(); - const emojiPath = path + '/' + exportId + '.' + mime.extension(emoji.type); + const ext = mime.extension(emoji.type); + const emojiPath = path + '/' + exportId + (ext ? '.' + ext : ''); fs.writeFileSync(emojiPath, '', 'binary'); let downloaded = false; From aedbab17cc400ae7ac17498463504f40646e8673 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 29 Dec 2021 17:21:08 +0900 Subject: [PATCH 02/13] revert d53795184 --- packages/backend/src/const.ts | 45 ------------------- .../src/server/file/send-drive-file.ts | 8 ++-- .../backend/src/server/proxy/proxy-media.ts | 3 +- .../backend/src/services/drive/add-file.ts | 2 - 4 files changed, 4 insertions(+), 54 deletions(-) diff --git a/packages/backend/src/const.ts b/packages/backend/src/const.ts index b00bd81655..43f59f1e4f 100644 --- a/packages/backend/src/const.ts +++ b/packages/backend/src/const.ts @@ -1,47 +1,2 @@ export const USER_ONLINE_THRESHOLD = 1000 * 60 * 10; // 10min export const USER_ACTIVE_THRESHOLD = 1000 * 60 * 60 * 24 * 3; // 3days - -// ブラウザで直接表示することを許可するファイルの種類のリスト -// ここに含まれないものは application/octet-stream としてレスポンスされる -// SVGはXSSを生むので許可しない -export const FILE_TYPE_BROWSERSAFE = [ - // Images - 'image/png', - 'image/gif', - 'image/jpeg', - 'image/webp', - 'image/apng', - 'image/bmp', - 'image/tiff', - 'image/x-icon', - - // OggS - 'audio/opus', - 'video/ogg', - 'audio/ogg', - 'application/ogg', - - // ISO/IEC base media file format - 'video/quicktime', - 'video/mp4', - 'audio/mp4', - 'video/x-m4v', - 'audio/x-m4a', - 'video/3gpp', - 'video/3gpp2', - - 'video/mpeg', - 'audio/mpeg', - - 'video/webm', - 'audio/webm', - - 'audio/aac', - 'audio/x-flac', - 'audio/vnd.wave', -]; -/* -https://github.com/sindresorhus/file-type/blob/main/supported.js -https://github.com/sindresorhus/file-type/blob/main/core.js -https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Containers -*/ diff --git a/packages/backend/src/server/file/send-drive-file.ts b/packages/backend/src/server/file/send-drive-file.ts index 7bfc36e25a..8bb5655b4f 100644 --- a/packages/backend/src/server/file/send-drive-file.ts +++ b/packages/backend/src/server/file/send-drive-file.ts @@ -14,7 +14,6 @@ import { detectType } from '@/misc/get-file-info'; import { convertToJpeg, convertToPngOrJpeg } from '@/services/drive/image-processor'; import { GenerateVideoThumbnail } from '@/services/drive/generate-video-thumbnail'; import { StatusError } from '@/misc/fetch'; -import { FILE_TYPE_BROWSERSAFE } from '@/const'; //const _filename = fileURLToPath(import.meta.url); const _filename = __filename; @@ -28,7 +27,6 @@ const commonReadableHandlerGenerator = (ctx: Koa.Context) => (e: Error): void => ctx.set('Cache-Control', 'max-age=300'); }; -// eslint-disable-next-line import/no-default-export export default async function(ctx: Koa.Context) { const key = ctx.params.key; @@ -83,7 +81,7 @@ export default async function(ctx: Koa.Context) { const image = await convertFile(); ctx.body = image.data; - ctx.set('Content-Type', FILE_TYPE_BROWSERSAFE.includes(image.type) ? image.type : 'application/octet-stream'); + ctx.set('Content-Type', image.type); ctx.set('Cache-Control', 'max-age=31536000, immutable'); } catch (e) { serverLogger.error(`${e}`); @@ -114,14 +112,14 @@ export default async function(ctx: Koa.Context) { }).toString(); ctx.body = InternalStorage.read(key); - ctx.set('Content-Type', FILE_TYPE_BROWSERSAFE.includes(mime) ? mime : 'application/octet-stream'); + ctx.set('Content-Type', mime); ctx.set('Cache-Control', 'max-age=31536000, immutable'); ctx.set('Content-Disposition', contentDisposition('inline', filename)); } else { const readable = InternalStorage.read(file.accessKey!); readable.on('error', commonReadableHandlerGenerator(ctx)); ctx.body = readable; - ctx.set('Content-Type', FILE_TYPE_BROWSERSAFE.includes(file.type) ? file.type : 'application/octet-stream'); + ctx.set('Content-Type', file.type); ctx.set('Cache-Control', 'max-age=31536000, immutable'); ctx.set('Content-Disposition', contentDisposition('inline', file.name)); } diff --git a/packages/backend/src/server/proxy/proxy-media.ts b/packages/backend/src/server/proxy/proxy-media.ts index b116b4b961..9e13c0877f 100644 --- a/packages/backend/src/server/proxy/proxy-media.ts +++ b/packages/backend/src/server/proxy/proxy-media.ts @@ -6,7 +6,6 @@ import { createTemp } from '@/misc/create-temp'; import { downloadUrl } from '@/misc/download-url'; import { detectType } from '@/misc/get-file-info'; import { StatusError } from '@/misc/fetch'; -import { FILE_TYPE_BROWSERSAFE } from '@/const'; export async function proxyMedia(ctx: Koa.Context) { const url = 'url' in ctx.query ? ctx.query.url : 'https://' + ctx.params.url; @@ -19,7 +18,7 @@ export async function proxyMedia(ctx: Koa.Context) { const { mime, ext } = await detectType(path); - if (!FILE_TYPE_BROWSERSAFE.includes(mime)) throw 403; + if (!mime.startsWith('image/')) throw 403; let image: IImage; diff --git a/packages/backend/src/services/drive/add-file.ts b/packages/backend/src/services/drive/add-file.ts index a59c9501bc..ee4d51a96d 100644 --- a/packages/backend/src/services/drive/add-file.ts +++ b/packages/backend/src/services/drive/add-file.ts @@ -20,7 +20,6 @@ import { isDuplicateKeyValueError } from '@/misc/is-duplicate-key-value-error'; import * as S3 from 'aws-sdk/clients/s3'; import { getS3 } from './s3'; import * as sharp from 'sharp'; -import { FILE_TYPE_BROWSERSAFE } from '@/const'; const logger = driveLogger.createSubLogger('register', 'yellow'); @@ -242,7 +241,6 @@ export async function generateAlts(path: string, type: string, generateWeb: bool */ async function upload(key: string, stream: fs.ReadStream | Buffer, type: string, filename?: string) { if (type === 'image/apng') type = 'image/png'; - if (!FILE_TYPE_BROWSERSAFE.includes(type)) type = 'application/octet-stream'; const meta = await fetchMeta(); From 1d640ee118c5f48a715ad9fd5c8d80511894390c Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 29 Dec 2021 17:23:58 +0900 Subject: [PATCH 03/13] Update CHANGELOG.md --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e363abe2b0..741d2cdb6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ --> +## 12.x.x (unreleased) + +### Improvements + +### Bugfixes +- SVG絵文字が表示できないのを修正 +- エクスポートした絵文字の拡張子がfalseになることがあるのを修正 + ## 12.101.0 (2021/12/29) ### Improvements From 99eb919f4ecdc76a54e6578a89b39439104b5a7c Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 29 Dec 2021 17:25:10 +0900 Subject: [PATCH 04/13] 12.101.1 --- CHANGELOG.md | 4 +--- package.json | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 741d2cdb6f..0fd61442e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,9 +7,7 @@ --> -## 12.x.x (unreleased) - -### Improvements +## 12.101.1 (2021/12/29) ### Bugfixes - SVG絵文字が表示できないのを修正 diff --git a/package.json b/package.json index 0c5becdede..c42b71582b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "misskey", - "version": "12.101.0", + "version": "12.101.1", "codename": "indigo", "repository": { "type": "git", From e159f1560018361de573c182b085c5aa12dc7840 Mon Sep 17 00:00:00 2001 From: tamaina Date: Wed, 29 Dec 2021 22:13:09 +0900 Subject: [PATCH 05/13] =?UTF-8?q?enhance:=20pizzax=E3=81=A7streaming?= =?UTF-8?q?=E3=81=AEuser=20storage=20update=E3=82=A4=E3=83=99=E3=83=B3?= =?UTF-8?q?=E3=83=88=E3=82=92=E7=9B=A3=E8=A6=96=E3=81=97=E3=81=A6=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=20(#8095)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * wip * wip? * ? * streamingのuser storage updateイベントを監視して更新 * 必要な時以外はストレージを更新しない * fix? * wip * fix * fix --- packages/client/src/components/drive.vue | 3 ++- .../client/src/components/follow-button.vue | 3 ++- .../client/src/components/note-detailed.vue | 3 ++- packages/client/src/components/note.vue | 3 ++- .../client/src/components/notification.vue | 5 +++-- .../client/src/components/notifications.vue | 5 +++-- packages/client/src/components/post-form.vue | 4 ++-- .../client/src/components/taskmanager.vue | 9 ++++---- packages/client/src/components/timeline.vue | 21 ++++++++++--------- packages/client/src/init.ts | 3 ++- packages/client/src/os.ts | 2 -- packages/client/src/pages/admin/metrics.vue | 5 +++-- packages/client/src/pages/admin/overview.vue | 3 ++- packages/client/src/pages/admin/queue.vue | 3 ++- packages/client/src/pages/messaging/index.vue | 3 ++- .../pages/messaging/messaging-room.form.vue | 3 ++- .../src/pages/messaging/messaging-room.vue | 3 ++- packages/client/src/pages/reversi/game.vue | 3 ++- packages/client/src/pages/reversi/index.vue | 3 ++- packages/client/src/pizzax.ts | 16 +++++++++++++- packages/client/src/scripts/select-file.ts | 3 ++- packages/client/src/stream.ts | 6 ++++++ packages/client/src/ui/_common_/common.vue | 3 ++- .../src/ui/_common_/stream-indicator.vue | 7 ++++--- packages/client/src/ui/chat/note.vue | 3 ++- packages/client/src/ui/chat/pages/channel.vue | 3 ++- .../client/src/ui/chat/pages/timeline.vue | 11 +++++----- packages/client/src/ui/chat/post-form.vue | 3 ++- packages/client/src/widgets/job-queue.vue | 3 ++- packages/client/src/widgets/photos.vue | 3 ++- .../src/widgets/server-metric/index.vue | 3 ++- 31 files changed, 98 insertions(+), 53 deletions(-) create mode 100644 packages/client/src/stream.ts diff --git a/packages/client/src/components/drive.vue b/packages/client/src/components/drive.vue index 46bcd42558..f8d3d810b7 100644 --- a/packages/client/src/components/drive.vue +++ b/packages/client/src/components/drive.vue @@ -53,6 +53,7 @@ import XFolder from './drive.folder.vue'; import XFile from './drive.file.vue'; import MkButton from './ui/button.vue'; import * as os from '@/os'; +import { stream } from '@/stream'; export default defineComponent({ components: { @@ -140,7 +141,7 @@ export default defineComponent({ }); } - this.connection = markRaw(os.stream.useChannel('drive')); + this.connection = markRaw(stream.useChannel('drive')); this.connection.on('fileCreated', this.onStreamDriveFileCreated); this.connection.on('fileUpdated', this.onStreamDriveFileUpdated); diff --git a/packages/client/src/components/follow-button.vue b/packages/client/src/components/follow-button.vue index 7136261914..b16b22f26f 100644 --- a/packages/client/src/components/follow-button.vue +++ b/packages/client/src/components/follow-button.vue @@ -30,6 +30,7 @@ diff --git a/packages/client/src/components/form/switch.vue b/packages/client/src/components/form/switch.vue index aa9b09215e..ac3284e7da 100644 --- a/packages/client/src/components/form/switch.vue +++ b/packages/client/src/components/form/switch.vue @@ -13,7 +13,8 @@ - + +

diff --git a/packages/client/src/components/user-select-dialog.vue b/packages/client/src/components/user-select-dialog.vue index ba2975478b..dbef34d547 100644 --- a/packages/client/src/components/user-select-dialog.vue +++ b/packages/client/src/components/user-select-dialog.vue @@ -1,5 +1,5 @@ -