Merge commit from fork

This commit is contained in:
Emrik Östling
2026-11-08 14:56:36 +01:00
committed by GitHub
parent cf64a613be
commit 7c6c8f16e5
3 changed files with 9 additions and 4 deletions
+4
View File
@@ -361,6 +361,10 @@ for (const converterName in properties) {
}
}
export const getTargetsForConverter = (converter: string): string[] => {
return allTargets[converter] || [];
};
export const getAllTargets = () => {
return allTargets;
};
+3 -2
View File
@@ -4,7 +4,7 @@ import { Elysia, t } from "elysia";
import sanitize from "sanitize-filename";
import { outputDir, uploadsDir } from "..";
import { handleConvert } from "../converters/main";
import { getTargetsForConverter, handleConvert } from "../converters/main";
import db from "../db/db";
import { Jobs } from "../db/types";
import { WEBROOT } from "../helpers/env";
@@ -53,7 +53,8 @@ export const convert = new Elysia().use(userService).post(
!converterName ||
convertTo.includes("/") ||
convertTo.includes("\\") ||
convertTo.includes("..")
convertTo.includes("..") ||
!getTargetsForConverter(converterName)?.includes(convertTo)
) {
return redirect(`${WEBROOT}/`, 302);
}
+2 -2
View File
@@ -127,13 +127,13 @@ describe("POST /convert", () => {
await convertRequest(
{ auth: user.token, jobId: job },
{ convert_to: "JPG,doesnotexist", file_names: '["photo.png"]' },
{ convert_to: "JPG,vips", file_names: '["photo.png"]' },
);
await waitFor(() => jobRow(job).status === "completed");
// jpg is normalized to jpeg, whose files get the .jpg extension
expect(fileRows(job)).toEqual([
{ file_name: "photo.png", output_file_name: "photo.jpg", status: "File type not supported" },
{ file_name: "photo.png", output_file_name: "photo.jpg", status: "Failed, check logs" },
]);
});