Revert "feat: enhance image upload validation across the application (#22766)"
This reverts commit 5acdb208f5.
This commit is contained in:
1 parent
3a0229f60d
commit
6a246e6c57
16 files changed
+64
-1128
No files matched your search
@@ -3,8 +3,6 @@ import type { NextApiRequest } from "next";
|
||||
import { HttpError } from "@calcom/lib/http-error";
|
||||
import { uploadAvatar } from "@calcom/lib/server/avatar";
|
||||
import { defaultResponder } from "@calcom/lib/server/defaultResponder";
|
||||
import { validateBase64Image } from "@calcom/lib/server/imageValidation";
|
||||
import { resizeBase64Image } from "@calcom/lib/server/resizeBase64Image";
|
||||
import prisma from "@calcom/prisma";
|
||||
import type { Prisma } from "@calcom/prisma/client";
|
||||
|
||||
@@ -126,25 +124,10 @@ export async function patchHandler(req: NextApiRequest) {
|
||||
}
|
||||
|
||||
if (avatar) {
|
||||
const validation = validateBase64Image(avatar);
|
||||
if (!validation.isValid) {
|
||||
throw new HttpError({
|
||||
statusCode: 400,
|
||||
message: `Invalid avatar image: ${validation.error}`,
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
body.avatarUrl = await uploadAvatar({
|
||||
userId: query.userId,
|
||||
avatar: await resizeBase64Image(avatar),
|
||||
});
|
||||
} catch (error) {
|
||||
throw new HttpError({
|
||||
statusCode: 400,
|
||||
message: error instanceof Error ? error.message : "Failed to upload avatar",
|
||||
});
|
||||
}
|
||||
body.avatarUrl = await uploadAvatar({
|
||||
userId: query.userId,
|
||||
avatar: await (await import("@calcom/lib/server/resizeBase64Image")).resizeBase64Image(avatar),
|
||||
});
|
||||
}
|
||||
|
||||
const data = await prisma.user.update({
|
||||
|
||||
@@ -6,7 +6,6 @@ import { z } from "zod";
|
||||
|
||||
import { AVATAR_FALLBACK, WEBAPP_URL } from "@calcom/lib/constants";
|
||||
import { convertSvgToPng } from "@calcom/lib/server/imageUtils";
|
||||
import { validateBase64Image } from "@calcom/lib/server/imageValidation";
|
||||
import prisma from "@calcom/prisma";
|
||||
|
||||
const querySchema = z.object({
|
||||
@@ -47,12 +46,6 @@ async function handler(req: NextRequest, { params }: { params: Promise<Params> }
|
||||
},
|
||||
});
|
||||
|
||||
const validation = validateBase64Image(data);
|
||||
if (!validation.isValid) {
|
||||
const url = new URL(AVATAR_FALLBACK, WEBAPP_URL).toString();
|
||||
return NextResponse.redirect(url, 302);
|
||||
}
|
||||
|
||||
// Convert SVG to PNG if needed and update the database
|
||||
if (data.startsWith("data:image/svg+xml;base64,")) {
|
||||
const pngData = await convertSvgToPng(data);
|
||||
@@ -79,11 +72,6 @@ async function handler(req: NextRequest, { params }: { params: Promise<Params> }
|
||||
"Content-Type": "image/png",
|
||||
"Content-Length": imageResp.length.toString(),
|
||||
"Cache-Control": "max-age=86400",
|
||||
// Security headers to prevent XSS
|
||||
"X-Content-Type-Options": "nosniff",
|
||||
"Content-Disposition": "inline",
|
||||
"X-Frame-Options": "DENY",
|
||||
"Content-Security-Policy": "default-src 'none'; img-src 'self'",
|
||||
},
|
||||
status: 200,
|
||||
});
|
||||
|
||||
@@ -3581,14 +3581,6 @@
|
||||
"webhook_metadata": "Metadata",
|
||||
"stats": "Stats",
|
||||
"booking_status": "Booking status",
|
||||
"unsupported_file_type": "{{type}} files cannot be uploaded as images",
|
||||
"only_image_files_allowed": "Only image files are allowed",
|
||||
"failed_to_validate_image_file": "Failed to validate image file",
|
||||
"invalid_image_file_format": "Invalid image file format",
|
||||
"svg_contains_dangerous_content": "SVG contains potentially dangerous content",
|
||||
"unrecognized_image_format": "Unrecognized image format or invalid file",
|
||||
"invalid_base64_format": "Invalid base64 format",
|
||||
"empty_image_data": "Empty image data",
|
||||
"visit": "Visit",
|
||||
"location_custom_label_input_label": "Custom label on booking page",
|
||||
"meeting_link": "Meeting link",
|
||||
|
||||
Reference in new issue
Block a user