summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2002-07-16 16:20:10 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2002-07-16 16:20:10 +0000
commitd11cb0f2c291ae0197922c695145e59103f28425 (patch)
treeac24a7d1eefb9744d692ebec1f0924ce7ac77321 /src/core
parentc9f5eafb3db1057f6911e56453e40556d4d06d5f (diff)
downloadirssi-d11cb0f2c291ae0197922c695145e59103f28425.zip
'\' characters in nicks were skipped when sending messages in queries.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2867 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/core')
-rw-r--r--src/core/misc.c16
-rw-r--r--src/core/misc.h3
2 files changed, 19 insertions, 0 deletions
diff --git a/src/core/misc.c b/src/core/misc.c
index 6bf87177..01ae0f1d 100644
--- a/src/core/misc.c
+++ b/src/core/misc.c
@@ -770,3 +770,19 @@ int expand_escape(const char **data)
return strtol(digit, NULL, 8);
}
}
+
+/* Escape all '"', "'" and '\' chars with '\' */
+char *escape_string(const char *str)
+{
+ char *ret, *p;
+
+ p = ret = g_malloc(strlen(str)*2+1);
+ while (*str != '\0') {
+ if (*str == '"' || *str == '\'' || *str == '\\')
+ *p++ = '\\';
+ *p++ = *str++;
+ }
+ *p = '\0';
+
+ return ret;
+}
diff --git a/src/core/misc.h b/src/core/misc.h
index 804cffc2..b9002c1c 100644
--- a/src/core/misc.h
+++ b/src/core/misc.h
@@ -105,4 +105,7 @@ GSList *columns_sort_list(GSList *list, int rows);
one after '\'. Returns the expanded character or -1 if error. */
int expand_escape(const char **data);
+/* Escape all '"', "'" and '\' chars with '\' */
+char *escape_string(const char *str);
+
#endif