mirror of
https://github.com/misskey-dev/media-proxy.git
synced 2025-04-29 02:47:26 +09:00
revert FILE_TYPE_BROWSERSAFE規制を復活
BROWSERSAFEではないならTYPE_OCTET_STREAMにする
This commit is contained in:
parent
b415f59b72
commit
ddc778d208
@ -26,6 +26,9 @@ export async function detectType(path) {
|
||||
if (type.mime === 'application/xml' && await checkSvg(path)) {
|
||||
return TYPE_SVG;
|
||||
}
|
||||
if (isMimeImage(type.mime, 'safe-file')) {
|
||||
return TYPE_OCTET_STREAM;
|
||||
}
|
||||
return {
|
||||
mime: type.mime,
|
||||
ext: type.ext,
|
||||
|
@ -3,7 +3,6 @@ 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';
|
||||
@ -149,9 +148,6 @@ 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),
|
||||
|
@ -34,6 +34,10 @@ export async function detectType(path: string): Promise<{
|
||||
return TYPE_SVG;
|
||||
}
|
||||
|
||||
if (isMimeImage(type.mime, 'safe-file')) {
|
||||
return TYPE_OCTET_STREAM;
|
||||
}
|
||||
|
||||
return {
|
||||
mime: type.mime,
|
||||
ext: type.ext,
|
||||
|
@ -191,8 +191,6 @@ 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