Trotzallem habe ich jetzt noch eine Frage:
Meine "Suchfunktion" sieht etwa so aus:
Code: Alles auswählen
def searchone(tag):
tag = "%"+tag+"%"
SQL = "SELECT id FROM news WHERE title LIKE %s OR summary LIKE %s"
connection = MySQLdb.connect(*utils.LOGIN)
cursor = connection.cursor()
rows = cursor.execute(SQL, (tag, tag))
results = getmany(map(lambda l: l[0], cursor.fetchall()))
connection.close()
return results
Wenn ich jetzt aber die Funktion auf folgende Weise aufrufe:
Code: Alles auswählen
results = searchone("cebit") # -> funktioniert alles super...
injection_example = "istmiregal%'; SELECT BENCHMARK(10000000, SHA1('test')) --"
r = searchone(injection_example) # -> wirft eine Fehlermeldung auf trotz escapen
...erhalte ich folgenden Fehler:
Code: Alles auswählen
ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1")
Die Bedeutung des Fehlers ist wieder klar jedoch frage ich mich, wie trotz dem escapen so einen Fehler aufrufen kann.
Liebe Grüße,
microkernel