No Input Sanitization #8
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
async def ask(interaction: discord.Interaction, question: str):
# Question sent directly to Ollama without sanitization
Fix:
def sanitize_input(text: str, max_length: int = 500) -> str:
"""Sanitize user input"""
text = text.strip()[:max_length]
# Remove potentially dangerous characters
text = ''.join(char for char in text if char.isprintable())
return text
In command:
question = sanitize_input(question, max_length=500)