fix: replace vulnerable email regex with safe helper function

- Use isValidEmail from helpers instead of inline regex
- Fixes SonarQube Security Hotspot for DoS via backtracking

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
soufiane 2025-12-05 14:44:51 +01:00
parent d192dad7e6
commit a80d42271d

View File

@ -7,6 +7,7 @@ import { registerSchema, RegisterFormData } from "@/lib/validations";
import Link from "next/link"; import Link from "next/link";
import TeaIconsBackground from "@/components/TeaIconsBackground"; import TeaIconsBackground from "@/components/TeaIconsBackground";
import { ROUTES, API_BASE_URL, API_ENDPOINTS } from "@/utils/constants"; import { ROUTES, API_BASE_URL, API_ENDPOINTS } from "@/utils/constants";
import { isValidEmail } from "@/utils/helpers";
import ReCAPTCHA from "react-google-recaptcha"; import ReCAPTCHA from "react-google-recaptcha";
export default function RegisterPage() { export default function RegisterPage() {
@ -42,7 +43,7 @@ export default function RegisterPage() {
// Vérifier si l'email existe déjà // Vérifier si l'email existe déjà
const checkEmail = async (email: string) => { const checkEmail = async (email: string) => {
if (!email || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) { if (!email || !isValidEmail(email)) {
setEmailStatus({ checking: false, exists: null, valid: null, message: '' }); setEmailStatus({ checking: false, exists: null, valid: null, message: '' });
return; return;
} }