fix: reject a trailing newline in sudo; test: malformed input suite

This commit is contained in:
Latte committed 2026-10-14 17:49:37 +02:00
1 parent 421a6507c0
commit 984673e8cf
2 files changed
+500 -1

No files matched your search

+2 -1
View File
@@ -273,7 +273,8 @@ def validate_sudo(sudo: Any) -> str | None:
"""Validate the optional ``sudo`` login (None when not given)."""
if sudo is None:
return None
if not isinstance(sudo, str) or not _SUDO_PATTERN.match(sudo):
# fullmatch: ``$`` would also accept a trailing newline.
if not isinstance(sudo, str) or not _SUDO_PATTERN.fullmatch(sudo):
raise ArgumentError("sudo must be a Gitea username (letters, digits, '-', '_', '.')")
return sudo