[giggle] Escape the commit message correctly



commit 9a8d291172621d4b6e26704d596e2c98fcacdcf5
Author: Denis Jasselette <denis jasselette yahoo fr>
Date:   Thu Jun 2 00:12:34 2011 +0200

    Escape the commit message correctly
    
    Fixes https://bugzilla.gnome.org/show_bug.cgi?id=638073

 libgiggle-git/giggle-git-commit.c |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)
---
diff --git a/libgiggle-git/giggle-git-commit.c b/libgiggle-git/giggle-git-commit.c
index 3c2d818..1a475b7 100644
--- a/libgiggle-git/giggle-git-commit.c
+++ b/libgiggle-git/giggle-git-commit.c
@@ -147,6 +147,25 @@ git_commit_set_property (GObject      *object,
 	}
 }
 
+static gchar *
+git_commit_escape_arg (gchar *arg)
+{
+	GString *escaped;
+	gunichar c;
+
+	escaped = g_string_new ("");
+	while ((c = g_utf8_get_char (arg))) {
+		if (c == '\\' || c == '"') {
+			g_string_append_c (escaped, '\\');
+		}
+
+		g_string_append_unichar (escaped, c);
+		arg = g_utf8_next_char (arg);
+	}
+
+	return g_string_free (escaped, FALSE);
+}
+
 static gboolean
 git_commit_get_command_line (GiggleJob *job, gchar **command_line)
 {
@@ -160,7 +179,7 @@ git_commit_get_command_line (GiggleJob *job, gchar **command_line)
 	str = g_string_new (GIT_COMMAND " commit");
 
 	if (priv->log) {
-		escaped = g_strescape (priv->log, "\b\f\n\r\t\\");
+		escaped = git_commit_escape_arg (priv->log);
 	} else {
 		escaped = g_strdup ("");
 	}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]