WebHost: Fix: strict suuid converter (#6130)

* WebHost: disallow '=' and whitespace in SUUID and append the correct number of '='

This makes Room IDs unambiguous and avoids breaking if b64decode ever becomes strict.

* Tests, WebHost: add SUUID tests

* Tests, WebHost: add edge cases to SUUID tests
This commit is contained in:
black-sliver
2026-04-13 20:17:27 +00:00
committed by GitHub
parent 37d32a10b1
commit 14aa6571de
3 changed files with 80 additions and 1 deletions

View File

@@ -71,7 +71,9 @@ CLI(app)
def to_python(value: str) -> uuid.UUID:
return uuid.UUID(bytes=base64.urlsafe_b64decode(value + '=='))
if "=" in value or any(c.isspace() for c in value):
raise ValueError("Invalid UUID format")
return uuid.UUID(bytes=base64.urlsafe_b64decode(value + '=' * (-len(value) % 4)))
def to_url(value: uuid.UUID) -> str: