mirror of
https://github.com/C4illin/ConvertX.git
synced 2026-11-08 22:40:21 +01:00
Merge commit from fork
This commit is contained in:
@@ -361,6 +361,10 @@ for (const converterName in properties) {
|
||||
}
|
||||
}
|
||||
|
||||
export const getTargetsForConverter = (converter: string): string[] => {
|
||||
return allTargets[converter] || [];
|
||||
};
|
||||
|
||||
export const getAllTargets = () => {
|
||||
return allTargets;
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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" },
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user