mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-01 00:26:38 +00:00
fix: validate media size dimensions
This commit is contained in:
@@ -241,6 +241,16 @@ describe("media-generation runtime shared normalization", () => {
|
||||
expect(deriveAspectRatioFromSize("1024x1536")).toBe("2:3");
|
||||
});
|
||||
|
||||
it("rejects unsafe size dimensions before deriving ratios", () => {
|
||||
expect(deriveAspectRatioFromSize("9007199254740993x3")).toBeUndefined();
|
||||
expect(
|
||||
resolveClosestSize({
|
||||
requestedSize: "9007199254740993x3",
|
||||
supportedSizes: ["1024x1024", "1536x1024"],
|
||||
}),
|
||||
).toBeUndefined();
|
||||
});
|
||||
|
||||
it("maps unsupported sizes to the closest supported size", () => {
|
||||
expect(
|
||||
resolveClosestSize({
|
||||
|
||||
@@ -311,6 +311,9 @@ function parseSizeValue(raw?: string | null): ParsedSize | null {
|
||||
if (!pair) {
|
||||
return null;
|
||||
}
|
||||
if (!Number.isSafeInteger(pair.width) || !Number.isSafeInteger(pair.height)) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
width: pair.width,
|
||||
height: pair.height,
|
||||
|
||||
Reference in New Issue
Block a user