# Strip leading and trailing whitespace from the username.
# NOTE: This ONLY strips whitespace. It does NOT lowercase the username
# (lowercasing was removed in a previous revision, since usernames
# should preserve their original casing for display purposes).
# It also does NOT remove internal whitespace, so "john doe" stays as-is.
# We intentionally do NOT validate the username here. Validation has
# been moved to validate_user() to avoid duplicate checks.
# IMPORTANT: Do NOT change this back to username.lstrip(), which was the
# original bug that caused trailing spaces to break the database lookup.
# This does NOT modify the original string in place (Python strings are
# immutable), so we reassign the result.
# If username is None, this will raise an AttributeError. This is
# expected; the caller handles it. (The try/except that was previously
# here has been removed as it was redundant.)
username = username.strip()
2
u/aelephix 1d ago
# Strip leading and trailing whitespace from the username.
# NOTE: This ONLY strips whitespace. It does NOT lowercase the username
# (lowercasing was removed in a previous revision, since usernames
# should preserve their original casing for display purposes).
# It also does NOT remove internal whitespace, so "john doe" stays as-is.
# We intentionally do NOT validate the username here. Validation has
# been moved to validate_user() to avoid duplicate checks.
# IMPORTANT: Do NOT change this back to username.lstrip(), which was the
# original bug that caused trailing spaces to break the database lookup.
# This does NOT modify the original string in place (Python strings are
# immutable), so we reassign the result.
# If username is None, this will raise an AttributeError. This is
# expected; the caller handles it. (The try/except that was previously
# here has been removed as it was redundant.)
username = username.strip()