Spaces:
Running
Running
| 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() |