Skip to content

Commit

Permalink
escaping all characters that are meaningful to SQL: sanitize the input
Browse files Browse the repository at this point in the history
  • Loading branch information
paulinohuerta committed Sep 15, 2017
1 parent f0a63e9 commit ebd94f1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dbhelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ def add_input(self, data):
try:
# The following introduces a deliberate security flaw.
#See section on SQL injection below
query = "INSERT INTO crimes (description) VALUES ('{}');".format(data)
query = "INSERT INTO crimes (description) VALUES (%s);".format(data)
with connection.cursor() as cursor:
cursor.execute(query)
cursor.execute(query,data)
connection.commit()
finally:
connection.close()
Expand Down

0 comments on commit ebd94f1

Please sign in to comment.