Answer the question
In order to leave comments, you need to log in
Escaping characters in QT?
I am writing a program that works with sqlite on QT 5.1. I just discovered with surprise that contrary to the documentation, there is no character escaping at all when preparing queries. That is, if you accidentally put a comma, quotes in the text, or even substitute SQL code, QT does not follow this in any way.
Sample code to illustrate:
QSqlQuery injectTest(db);
QString test("asdasd, asd,' , ");
injectTest.prepare("UPDATE testtable SET text = :text WHERE id = 0");
injectTest.bindValue(":text", QVariant(test));
injectTest.exec();
UPDATE testtable SET text = asdasd, asd,' ,
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question