aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Toshok <toshok@ximian.com>2002-02-19 08:06:39 +0800
committerChris Toshok <toshok@src.gnome.org>2002-02-19 08:06:39 +0800
commitd866ac96b14cef65c5d116f5ec4b047025c3be98 (patch)
tree61e01fa5d6a465e9265df28501de56e27ed821ff
parent8432a4bc32ef9c15a18c39ca9eacd86a6e51c1b2 (diff)
downloadgsoc2013-evolution-d866ac96b14cef65c5d116f5ec4b047025c3be98.tar
gsoc2013-evolution-d866ac96b14cef65c5d116f5ec4b047025c3be98.tar.gz
gsoc2013-evolution-d866ac96b14cef65c5d116f5ec4b047025c3be98.tar.bz2
gsoc2013-evolution-d866ac96b14cef65c5d116f5ec4b047025c3be98.tar.lz
gsoc2013-evolution-d866ac96b14cef65c5d116f5ec4b047025c3be98.tar.xz
gsoc2013-evolution-d866ac96b14cef65c5d116f5ec4b047025c3be98.tar.zst
gsoc2013-evolution-d866ac96b14cef65c5d116f5ec4b047025c3be98.zip
escape commas in the dn, since they're used by ldap to specify the node's
2002-02-18 Chris Toshok <toshok@ximian.com> * backend/pas/pas-backend-ldap.c (create_dn_from_ecard): escape commas in the dn, since they're used by ldap to specify the node's placement in the tree. (fixes bug 20089) (rfc2254_escape): just use sprintf and %02X instead. svn path=/trunk/; revision=15756
-rw-r--r--addressbook/ChangeLog7
-rw-r--r--addressbook/backend/pas/pas-backend-ldap.c29
2 files changed, 29 insertions, 7 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 4bfaccc9ee..9bb07ebb63 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,10 @@
+2002-02-18 Chris Toshok <toshok@ximian.com>
+
+ * backend/pas/pas-backend-ldap.c (create_dn_from_ecard): escape
+ commas in the dn, since they're used by ldap to specify the node's
+ placement in the tree. (fixes bug 20089)
+ (rfc2254_escape): just use sprintf and %02X instead.
+
2002-02-13 Christopher James Lahey <clahey@ximian.com>
* gui/component/select-names/e-select-names.c (set_book): Keep a
diff --git a/addressbook/backend/pas/pas-backend-ldap.c b/addressbook/backend/pas/pas-backend-ldap.c
index cfd6b0d1d5..3071fa7e45 100644
--- a/addressbook/backend/pas/pas-backend-ldap.c
+++ b/addressbook/backend/pas/pas-backend-ldap.c
@@ -586,11 +586,29 @@ create_dn_from_ecard (ECardSimple *card, const char *root_dn)
{
char *cn, *cn_part = NULL;
char *dn;
- gboolean need_comma = FALSE;
cn = e_card_simple_get (card, E_CARD_SIMPLE_FIELD_FULL_NAME);
if (cn) {
- cn_part = g_strdup_printf ("cn=%s%s", cn, need_comma ? "," : "");
+ if (strchr (cn, ',')) {
+ /* need to escape commas */
+ char *new_cn = g_malloc0 (strlen (cn) * 3 + 1);
+ int i, j;
+
+ for (i = 0, j = 0; i < strlen (cn); i ++) {
+ if (cn[i] == ',') {
+ sprintf (new_cn + j, "%%%02X", cn[i]);
+ j += 3;
+ }
+ else {
+ new_cn[j++] = cn[i];
+ }
+ }
+ cn_part = g_strdup_printf ("cn=%s", new_cn);
+ g_free (new_cn);
+ }
+ else {
+ cn_part = g_strdup_printf ("cn=%s", cn);
+ }
}
else {
cn_part = g_strdup ("");
@@ -1766,7 +1784,6 @@ birthday_compare (ECardSimple *ecard1, ECardSimple *ecard2)
}
#define IS_RFC2254_CHAR(c) ((c) == '*' || (c) =='\\' || (c) == '(' || (c) == ')' || (c) == '\0')
-static char hex[] = "0123456789abcdef";
static char *
rfc2254_escape(char *str)
{
@@ -1789,9 +1806,8 @@ rfc2254_escape(char *str)
int j = 0;
for (i = 0; i < len; i ++) {
if (IS_RFC2254_CHAR(str[i])) {
- newstr[j++] = '\\';
- newstr[j++] = hex[(str[i]&0xf0) >> 4];
- newstr[j++] = hex[str[i]&0x0f];
+ sprintf (newstr + j, "\\%02x", str[i]);
+ j+= 3;
}
else {
newstr[j++] = str[i];
@@ -1799,7 +1815,6 @@ rfc2254_escape(char *str)
}
return newstr;
}
-
}
static ESExpResult *