Skip to content

Commit cd97c63

Browse files
committed
Fix bug in regex for usernames
1 parent 30d012b commit cd97c63

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

app/util/approve.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,17 @@ def __init__(self):
3434
def sanitize_username(username: str) -> str:
3535
"""Strip invalid characters from username"""
3636
# Remove characters: <>& "' spaces tabs vertical tabs $%!#?§,;:*~/\|^=[]{}()`
37-
invalid_chars = r"[<>&\"'\\s\\v\\h$%!#?§,;:*~/\\|^=\[\]{}()`]"
37+
invalid_chars = r"[<>&\"'\s\v\t$%!#?§,;:*~/\\|^=\[\]{}()`]"
3838
return re.sub(invalid_chars, "", username)
3939

4040
@staticmethod
4141
def sanitize_name(name: str) -> str:
4242
"""Strip invalid characters from first and last names"""
43-
# Remove characters: <>& " vertical tabs $%!#?§;*~/\|^=[]{}()
43+
# Remove dangerous characters but keep common name chars like hyphens, apostrophes, spaces
4444
invalid_chars = r"[<>&\"\v$%!#?§;*~/\\|^=\[\]{}()]"
45-
return re.sub(invalid_chars, "", name)
45+
result = re.sub(invalid_chars, "", name)
46+
logger.debug(f"sanitize_name: '{name}' -> '{result}'")
47+
return result
4648

4749
def provision_infra(
4850
member_id: uuid.UUID,

0 commit comments

Comments
 (0)