sanitize nul char in totp content (#2186)

This commit is contained in:
Shuchang Zheng
2025-04-19 03:02:39 +08:00
committed by GitHub
parent 695d524575
commit e6c95cc987
2 changed files with 27 additions and 1 deletions

View File

@@ -0,0 +1,18 @@
"""
Utility functions for sanitizing content before storing in the database.
"""
def sanitize_postgres_text(text: str) -> str:
"""
Sanitize text to be stored in PostgreSQL by removing NUL bytes.
PostgreSQL text fields cannot contain NUL (0x00) bytes, so we remove them.
Args:
text: The text to sanitize
Returns:
The sanitized text without NUL bytes
"""
return text.replace("\0", "")