fix: allow accented characters in player and guest names
Extend validation regex to include Latin Extended Unicode range (\u00C0-\u024F) covering é, è, à, ü, ö, etc. in backend and frontend. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
a141cd32f2
commit
35119f796f
8
app.py
8
app.py
@ -122,12 +122,10 @@ def db_to_json():
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
def validate_player_name(name):
|
def validate_player_name(name):
|
||||||
# Only allow a-z, A-Z, 0-9, spaces, hyphens, and periods, max 50 chars
|
return bool(re.fullmatch(r'[a-zA-Z0-9\u00C0-\u024F .-]{1,50}', name))
|
||||||
return bool(re.fullmatch(r'[a-zA-Z0-9 .-]{1,50}', name))
|
|
||||||
|
|
||||||
def validate_guest_name(name):
|
def validate_guest_name(name):
|
||||||
# Only allow a-z, A-Z, 0-9, spaces, hyphens, and periods, max 50 chars
|
return bool(re.fullmatch(r'[a-zA-Z0-9\u00C0-\u024F .-]{1,50}', name))
|
||||||
return bool(re.fullmatch(r'[a-zA-Z0-9 .-]{1,50}', name))
|
|
||||||
|
|
||||||
def validate_date_str(date_str):
|
def validate_date_str(date_str):
|
||||||
# Format: DD/MM/YY
|
# Format: DD/MM/YY
|
||||||
@ -252,7 +250,7 @@ def get_players():
|
|||||||
def add_player():
|
def add_player():
|
||||||
data = request.json
|
data = request.json
|
||||||
name = (data.get('name') or '').strip()
|
name = (data.get('name') or '').strip()
|
||||||
if not re.fullmatch(r'[a-zA-Z0-9 .\-]{1,50}', name):
|
if not re.fullmatch(r'[a-zA-Z0-9\u00C0-\u024F .\-]{1,50}', name):
|
||||||
return jsonify({'status': 'error', 'message': 'Invalid name'}), 400
|
return jsonify({'status': 'error', 'message': 'Invalid name'}), 400
|
||||||
if Player.query.filter_by(name=name).first():
|
if Player.query.filter_by(name=name).first():
|
||||||
return jsonify({'status': 'error', 'message': 'Player already exists'}), 400
|
return jsonify({'status': 'error', 'message': 'Player already exists'}), 400
|
||||||
|
|||||||
@ -178,7 +178,7 @@ function renderTable() {
|
|||||||
guestNameInput.value = data.guestNames[date] || '';
|
guestNameInput.value = data.guestNames[date] || '';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!/^([a-zA-Z0-9 .-]+)$/.test(value)) {
|
if (!/^[a-zA-Z0-9\u00C0-\u024F .-]+$/.test(value)) {
|
||||||
alert('Guest name can only contain letters, numbers, spaces, hyphens, and periods.');
|
alert('Guest name can only contain letters, numbers, spaces, hyphens, and periods.');
|
||||||
guestNameInput.value = data.guestNames[date] || '';
|
guestNameInput.value = data.guestNames[date] || '';
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -406,7 +406,7 @@
|
|||||||
const name = nameInput.value.trim();
|
const name = nameInput.value.trim();
|
||||||
msg.textContent = '';
|
msg.textContent = '';
|
||||||
|
|
||||||
if (!/^[a-zA-Z0-9 .\-]{1,50}$/.test(name)) {
|
if (!/^[a-zA-Z0-9\u00C0-\u024F .\-]{1,50}$/.test(name)) {
|
||||||
msg.className = 'msg err';
|
msg.className = 'msg err';
|
||||||
msg.textContent = 'Invalid name. Use letters, numbers, spaces, hyphens, or periods (max 50 chars).';
|
msg.textContent = 'Invalid name. Use letters, numbers, spaces, hyphens, or periods (max 50 chars).';
|
||||||
return;
|
return;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user