Spaces:
Running
Running
File size: 413 Bytes
93f031b | 1 2 3 4 5 6 7 8 9 10 11 | import re
def sanitize_input(text: str) -> str:
"""Sanea la entrada del usuario eliminando intentos de romper comillas triples y caracteres de control."""
if not text:
return ""
# Escapar comillas triples
text = text.replace('"""', '\"\"\"')
# Remover caracteres nulos o no imprimibles
text = re.sub(r'[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]', '', text)
return text.strip() |