Merge pull request #476 from alliedmodders/query-format

Implement an auto-escaping Format native for SQL query construction
This commit is contained in:
Asher Baker
2016-10-03 16:20:01 +01:00
committed by GitHub
8 changed files with 208 additions and 92 deletions
+12
View File
@@ -84,6 +84,18 @@ IDBDriver *SqDatabase::GetDriver()
bool SqDatabase::QuoteString(const char *str, char buffer[], size_t maxlen, size_t *newSize)
{
unsigned long size = static_cast<unsigned long>(strlen(str));
unsigned long needed = size * 2 + 1;
if (maxlen < needed)
{
if (newSize != NULL)
{
*newSize = (size_t)needed;
}
return false;
}
char *res = sqlite3_snprintf(static_cast<int>(maxlen), buffer, "%q", str);
if (res != NULL && newSize != NULL)