fix: secure email regex against ReDoS vulnerability
- Replace vulnerable regex with bounded quantifiers - Add email length check (max 254 chars per RFC 5321) - Fixes SonarQube security hotspot S5852 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
47059a5129
commit
d4c2252121
|
|
@ -42,7 +42,9 @@ 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)) {
|
// Regex sécurisée contre ReDoS avec limite de longueur
|
||||||
|
const isValidEmail = email && email.length <= 254 && /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(email);
|
||||||
|
if (!isValidEmail) {
|
||||||
setEmailStatus({ checking: false, exists: null, valid: null, message: '' });
|
setEmailStatus({ checking: false, exists: null, valid: null, message: '' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user