mirror of
https://github.com/misskey-dev/media-proxy.git
synced 2025-04-29 02:47:26 +09:00
FILE_TYPE_BROWSERSAFE規制を復活
This commit is contained in:
parent
0ca08c2c50
commit
b415f59b72
@ -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),
|
||||
|
@ -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",
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user