Is
MATCHfrom MySQL also vulnerable to injection attack? For example:"""SELECT * FROM myTable WHERE MATCH(myColumnName) AGAINST(%s) ORDER BY id LIMIT 20""" % queryseems to allow arbitrary strings, which looks bad.
If so, I've instead tried - following examples in the Python docs -
t = (query,) statement = """SELECT * FROM myTable WHERE MATCH(myColumnName) AGAINST(?) ORDER BY id LIMIT 20""" cursor.execute(statement, t)but nothing is returned - even when the string
queryreturned hits in (1) above. Why is that?In 2), using the placeholder
%sinstead of?returns results. Why is this safer than 1) (if at all)? E.g. with the query string I can always close off a string and parenthesis withquery=')...'and continuequery=') OR otherColumnName LIKE '%hello%' --.
Therefore, is it enough to strip query strings of everything but roman characters or numerals?