Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions code/src/api/v1/controllers/postRemoveBackground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ export const postRemoveBackgroundController = () => {
return async (req: Request, res: Response): Promise<void> => {
const roomId = req.params.roomId;
const imageId = req.params.imageId;
// Validate roomId and imageId to prevent path traversal and unsafe characters
if (
!roomId ||
!imageId ||
!/^[a-zA-Z0-9_-]+$/.test(roomId) ||
!/^[a-zA-Z0-9_-]+$/.test(imageId)
) {
res.status(400).json({ status: "KO", message: "Invalid roomId or imageId." });
return;
}
const {
image: { dataBase64, contentType },
} = req.body;
Expand Down
Loading