From 980a2edce8fd7c33c8f36071f9c59ecd2a88cac4 Mon Sep 17 00:00:00 2001 From: brain Date: Thu, 15 Jun 2006 13:04:07 +0000 Subject: Nicer SQLQuery::Sanitise git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4006 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/extra/m_sql.h | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/modules/extra/m_sql.h b/src/modules/extra/m_sql.h index 2e185d978..519b28f33 100644 --- a/src/modules/extra/m_sql.h +++ b/src/modules/extra/m_sql.h @@ -234,21 +234,27 @@ class SQLQuery static std::string Sanitise(const std::string& crap) { - std::string temp = ""; - for (unsigned int q = 0; q < crap.length(); q++) - { - if (crap[q] == '\'') + std::string temp = ""; + for (unsigned int q = 0; q < crap.length(); q++) + { + if (crap[q] == '\'') { - temp = temp + "\'"; + temp += "\\'"; } - else if (crap[q] == '"') + else if (crap[q] == '"') { - temp = temp + "\\\""; + temp += "\\\""; } - else - temp = temp + crap[q]; - } - return temp; + else if (crap[q] == '\\') + { + temp += "\\\\"; + } + else + { + temp += crap[q]; + } + } + return temp; } }; -- cgit v1.2.3