FILE_TYPE_BROWSERSAFE規制を復活

This commit is contained in:
tamaina 2023-02-09 12:43:07 +00:00
parent 0ca08c2c50
commit b415f59b72
3 changed files with 7 additions and 1 deletions

View File

@ -3,6 +3,7 @@ import { fileURLToPath } from 'node:url';
import { dirname } from 'node:path';
import fastifyStatic from '@fastify/static';
import { createTemp } from './create-temp.js';
import { FILE_TYPE_BROWSERSAFE } from './const.js';
import { convertToWebpStream, webpDefault } from './image-processor.js';
import { detectType, isMimeImage } from './file-info.js';
import sharp from 'sharp';
@ -148,6 +149,9 @@ async function proxyHandler(request, reply) {
else if (file.mime === 'image/svg+xml') {
image = convertToWebpStream(file.path, 2048, 2048);
}
else if (!file.mime.startsWith('image/') || !FILE_TYPE_BROWSERSAFE.includes(file.mime)) {
throw new StatusError('Rejected type', 403, 'Rejected type');
}
if (!image) {
image = {
data: fs.createReadStream(file.path),

View File

@ -1,6 +1,6 @@
{
"name": "misskey-media-proxy",
"version": "0.0.6",
"version": "0.0.9",
"description": "The Media Proxy for Misskey",
"main": "built/index.js",
"packageManager": "pnpm@7.26.0",

View File

@ -191,6 +191,8 @@ async function proxyHandler(request: FastifyRequest<{ Params: { url: string; };
};
} else if (file.mime === 'image/svg+xml') {
image = convertToWebpStream(file.path, 2048, 2048);
} else if (!file.mime.startsWith('image/') || !FILE_TYPE_BROWSERSAFE.includes(file.mime)) {
throw new StatusError('Rejected type', 403, 'Rejected type');
}
if (!image) {