[gnome-keyring] [dbus] Fix encoding problems with keyring names and foreign characters.
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-keyring] [dbus] Fix encoding problems with keyring names and foreign characters.
- Date: Tue, 27 Jul 2010 10:38:40 +0000 (UTC)
commit 9072f847743e22eb6a96c70d1cac8bf506df8902
Author: Stef Walter <stef memberwebs com>
Date: Tue Jul 27 10:23:52 2010 +0200
[dbus] Fix encoding problems with keyring names and foreign characters.
* Creating keyrings with a label that contained non-ascii charaters
was broken.
configure.in | 1 +
daemon/dbus/Makefile.am | 9 +++++++
daemon/dbus/gkd-secret-util.c | 2 +-
daemon/dbus/tests/Makefile.am | 14 +++++++++++
daemon/dbus/tests/test-secret-util.c | 42 ++++++++++++++++++++++++++++++++++
5 files changed, 67 insertions(+), 1 deletions(-)
---
diff --git a/configure.in b/configure.in
index b68921c..e3a14ca 100644
--- a/configure.in
+++ b/configure.in
@@ -614,6 +614,7 @@ daemon/control/Makefile
daemon/control/tests/Makefile
daemon/data/Makefile
daemon/dbus/Makefile
+daemon/dbus/tests/Makefile
daemon/gpg-agent/Makefile
daemon/login/Makefile
daemon/ssh-agent/Makefile
diff --git a/daemon/dbus/Makefile.am b/daemon/dbus/Makefile.am
index 20ecca8..efc3041 100644
--- a/daemon/dbus/Makefile.am
+++ b/daemon/dbus/Makefile.am
@@ -36,3 +36,12 @@ libgkd_dbus_la_LIBADD = \
$(GLIB_LIBS) \
$(GOBJECT_LIBS)
+# -------------------------------------------------------------------
+
+if WITH_TESTS
+TESTS_DIR = tests
+else
+TESTS_DIR =
+endif
+
+SUBDIRS = . $(TESTS_DIR)
diff --git a/daemon/dbus/gkd-secret-util.c b/daemon/dbus/gkd-secret-util.c
index b72f5b6..9ccc14f 100644
--- a/daemon/dbus/gkd-secret-util.c
+++ b/daemon/dbus/gkd-secret-util.c
@@ -141,7 +141,7 @@ gkd_secret_util_build_path (const gchar *base, gconstpointer identifier, gssize
/* Special characters are encoded with a _ */
} else {
- g_string_append_printf (result, "_%02x", (unsigned int)ch);
+ g_string_append_printf (result, "_%02x", (unsigned int)(unsigned char)ch);
}
}
diff --git a/daemon/dbus/tests/Makefile.am b/daemon/dbus/tests/Makefile.am
new file mode 100644
index 0000000..cea737b
--- /dev/null
+++ b/daemon/dbus/tests/Makefile.am
@@ -0,0 +1,14 @@
+
+# Test files should be listed in order they need to run
+TESTING_FILES = \
+ test-secret-util.c
+
+TESTING_LIBS = \
+ $(top_builddir)/daemon/dbus/libgkd-dbus.la
+
+TESTING_FLAGS = \
+ $(DAEMON_CFLAGS) \
+ $(GOBJECT_CFLAGS) \
+ $(GLIB_CFLAGS)
+
+include $(top_srcdir)/testing/testing.make
diff --git a/daemon/dbus/tests/test-secret-util.c b/daemon/dbus/tests/test-secret-util.c
new file mode 100644
index 0000000..8a981e7
--- /dev/null
+++ b/daemon/dbus/tests/test-secret-util.c
@@ -0,0 +1,42 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* test-secret-util.c: Test secret utils
+
+ Copyright (C) 2010 Stefan Walter
+
+ The Gnome Keyring Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The Gnome Keyring Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the Gnome Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+ Author: Stef Walter <stef memberwebs com>
+*/
+
+#include "config.h"
+
+#include "test-suite.h"
+
+#include "dbus/gkd-secret-util.h"
+
+#include <glib.h>
+
+DEFINE_TEST(secret_util_build_path)
+{
+ const gchar *identifier = "par_d\xc3\xa9""faut";
+ gchar *result;
+
+ result = gkd_secret_util_build_path ("/path/", identifier, strlen (identifier));
+ g_assert (result);
+
+ g_assert_cmpstr (result, ==, "/path/par_5fd_c3_a9faut");
+ g_free (result);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]