refactor: update MITM bypass logic and enhance combo name validation

This commit is contained in:
decolua 2026-03-19 22:47:32 +07:00
parent a0500dfc85
commit f1c53a319e
6 changed files with 54 additions and 62 deletions

View file

@ -2,7 +2,7 @@ import { NextResponse } from "next/server";
import { getComboById, updateCombo, deleteCombo, getComboByName } from "@/lib/localDb";
// Validate combo name: only a-z, A-Z, 0-9, -, _
const VALID_NAME_REGEX = /^[a-zA-Z0-9_-]+$/;
const VALID_NAME_REGEX = /^[a-zA-Z0-9_.\-]+$/;
// GET /api/combos/[id] - Get combo by ID
export async function GET(request, { params }) {
@ -30,7 +30,7 @@ export async function PUT(request, { params }) {
// Validate name format if provided
if (body.name) {
if (!VALID_NAME_REGEX.test(body.name)) {
return NextResponse.json({ error: "Name can only contain letters, numbers, - and _" }, { status: 400 });
return NextResponse.json({ error: "Name can only contain letters, numbers, -, _ and ." }, { status: 400 });
}
// Check if name already exists (exclude current combo)

View file

@ -4,7 +4,7 @@ import { getCombos, createCombo, getComboByName } from "@/lib/localDb";
export const dynamic = "force-dynamic";
// Validate combo name: only a-z, A-Z, 0-9, -, _
const VALID_NAME_REGEX = /^[a-zA-Z0-9_-]+$/;
const VALID_NAME_REGEX = /^[a-zA-Z0-9_.\-]+$/;
// GET /api/combos - Get all combos
export async function GET() {
@ -29,7 +29,7 @@ export async function POST(request) {
// Validate name format
if (!VALID_NAME_REGEX.test(name)) {
return NextResponse.json({ error: "Name can only contain letters, numbers, - and _" }, { status: 400 });
return NextResponse.json({ error: "Name can only contain letters, numbers, -, _ and ." }, { status: 400 });
}
// Check if name already exists