[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnokii] 01/01: SQLite module: added a function that escapes only single
From: |
Jan Derfinak |
Subject: |
[gnokii] 01/01: SQLite module: added a function that escapes only single quotes by putting two single quotes in a row as SQLite likes them. Author Pedro Aguilar. |
Date: |
Fri, 23 May 2014 23:19:25 +0000 |
ja pushed a commit to branch master
in repository gnokii.
commit 75bb5515ec7a48985d001e47ba2049acb76b04d0
Author: Jan Derfinak <address@hidden>
Date: Sat May 24 01:16:53 2014 +0200
SQLite module: added a function that escapes only single quotes by putting
two single quotes in a row as SQLite likes them. Author Pedro Aguilar.
---
smsd/ChangeLog | 10 ++++++++++
smsd/sqlite.c | 2 +-
smsd/utils.c | 23 +++++++++++++++++++++++
smsd/utils.h | 1 +
4 files changed, 35 insertions(+), 1 deletions(-)
diff --git a/smsd/ChangeLog b/smsd/ChangeLog
index 054d237..568a63f 100644
--- a/smsd/ChangeLog
+++ b/smsd/ChangeLog
@@ -1,3 +1,13 @@
+* Sat 24 May 2014 Jan Derfinak
+- SQLite module: added a function that escapes only single quotes by putting
+ two single quotes in a row as SQLite likes them. Author Pedro Aguilar.
+
+
+* Sat 24 May 2014 Jan Derfinak
+- SQLite module: fixed inserting the month number in inbox table.
+ Author Pedro Aguilar.
+
+
* Wed 27 Mar 2013 Jan Derfinak
- Removed one second sleep in resend loop after a successfull send. (Pedro
Aguilar)
diff --git a/smsd/sqlite.c b/smsd/sqlite.c
index cf9b313..5e00607 100644
--- a/smsd/sqlite.c
+++ b/smsd/sqlite.c
@@ -75,7 +75,7 @@ GNOKII_API gint DB_InsertSMS(const gn_sms * const data, const
gchar * const phon
}
text = g_string_sized_new(480);
- g_string_append(text, strEscape((gchar *) data->user_data[0].u.text));
+ g_string_append(text, strEscapeSingleQuote((gchar *)
data->user_data[0].u.text));
time(&rawtime);
timeinfo = localtime(&rawtime);
diff --git a/smsd/utils.c b/smsd/utils.c
index 73d8066..ed890bd 100644
--- a/smsd/utils.c
+++ b/smsd/utils.c
@@ -38,3 +38,26 @@ gchar *strEscape (const gchar *const s)
return (ret);
}
+/* Escapes ' with '' */
+/* SQLite escapes the single quote by puttin two of them in a row, */
+/* it doesn't need to escape the backslash */
+/* Returned value needs to be free with g_free(). */
+gchar *strEscapeSingleQuote (const gchar *const s)
+{
+ GString *str = g_string_new (s);
+ register gint i = 0;
+ gchar *ret;
+
+ while (str->str[i] != '\0')
+ {
+ if (str->str[i] == '\'')
+ g_string_insert_c (str, i++, '\'');
+ i++;
+ }
+
+ ret = str->str;
+ g_string_free (str, FALSE);
+
+ return (ret);
+}
+
diff --git a/smsd/utils.h b/smsd/utils.h
index d9a6fbf..ffb6ca7 100644
--- a/smsd/utils.h
+++ b/smsd/utils.h
@@ -19,5 +19,6 @@
#include <glib.h>
extern gchar *strEscape (const gchar *const s);
+extern gchar *strEscapeSingleQuote (const gchar *const s);
#endif /* __smsd_utils_h_ */
- [gnokii] branch master updated (9a69347 -> 75bb551), Jan Derfinak, 2014/05/24
- [gnokii] 01/01: SQLite module: added a function that escapes only single quotes by putting two single quotes in a row as SQLite likes them. Author Pedro Aguilar.,
Jan Derfinak <=