Bird
0
0

What is wrong with this Flask input sanitization code?

medium📝 Debug Q7 of 15
Flask - Security Best Practices
What is wrong with this Flask input sanitization code?
from flask import escape, request
user_input = request.args.get('data')
safe_input = user_input
Aescape() is called twice unnecessarily
BInput is not sanitized before use
Crequest.args.get() cannot get query parameters
Dsafe_input should be converted to int
Step-by-Step Solution
Solution:
  1. Step 1: Analyze sanitization usage

    escape() is imported but not used; input is assigned directly.
  2. Step 2: Check other options

    request.args.get() correctly gets query params; no need to convert to int here.
  3. Final Answer:

    Input is not sanitized before use -> Option B
  4. Quick Check:

    Missing escape() call = no sanitization [OK]
Quick Trick: Always apply escape() to user input before use [OK]
Common Mistakes:
MISTAKES
  • Importing but not using escape()
  • Misunderstanding request.args.get()
  • Unnecessary type conversion

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes