aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@helixcode.com>2000-09-20 03:11:15 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2000-09-20 03:11:15 +0800
commitefc4149c783f869f856a022acc67612efcce430e (patch)
tree9257cfbdc8581f4d92c3846f5d1a883c8c92fef2 /camel
parent64b4dc6796efd18570bb8d35332928ee46addc92 (diff)
downloadgsoc2013-evolution-efc4149c783f869f856a022acc67612efcce430e.tar
gsoc2013-evolution-efc4149c783f869f856a022acc67612efcce430e.tar.gz
gsoc2013-evolution-efc4149c783f869f856a022acc67612efcce430e.tar.bz2
gsoc2013-evolution-efc4149c783f869f856a022acc67612efcce430e.tar.lz
gsoc2013-evolution-efc4149c783f869f856a022acc67612efcce430e.tar.xz
gsoc2013-evolution-efc4149c783f869f856a022acc67612efcce430e.tar.zst
gsoc2013-evolution-efc4149c783f869f856a022acc67612efcce430e.zip
When encoding the internet address, quote the name as the name may have
2000-09-19 Jeffrey Stedfast <fejj@helixcode.com> * camel-internet-address.c (internet_encode): When encoding the internet address, quote the name as the name may have commas or any other token which may later confuse our address parser. svn path=/trunk/; revision=5506
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog6
-rw-r--r--camel/camel-internet-address.c67
2 files changed, 42 insertions, 31 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index b114f309e2..5436a90bc7 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,9 @@
+2000-09-19 Jeffrey Stedfast <fejj@helixcode.com>
+
+ * camel-internet-address.c (internet_encode): When encoding the
+ internet address, quote the name as the name may have commas or
+ any other token which may later confuse our address parser.
+
2000-09-19 Dan Winship <danw@helixcode.com>
* providers/imap/camel-imap-folder.c
diff --git a/camel/camel-internet-address.c b/camel/camel-internet-address.c
index 65b7e1dfaf..712b611741 100644
--- a/camel/camel-internet-address.c
+++ b/camel/camel-internet-address.c
@@ -74,74 +74,79 @@ static int
internet_decode (CamelAddress *a, const char *raw)
{
struct _header_address *ha, *n;
-
+
/* Should probably use its own decoder or something */
- ha = header_address_decode(raw);
+ ha = header_address_decode (raw);
if (ha) {
n = ha;
while (n) {
if (n->type == HEADER_ADDRESS_NAME) {
- camel_internet_address_add((CamelInternetAddress *)a, n->name, n->v.addr);
+ camel_internet_address_add ((CamelInternetAddress *)a, n->name, n->v.addr);
} else if (n->type == HEADER_ADDRESS_GROUP) {
struct _header_address *g = n->v.members;
while (g) {
if (g->type == HEADER_ADDRESS_NAME)
- camel_internet_address_add((CamelInternetAddress *)a, g->name, g->v.addr);
+ camel_internet_address_add ((CamelInternetAddress *)a, g->name, g->v.addr);
/* otherwise, its an error, infact */
g = g->next;
}
}
n = n->next;
}
- header_address_list_clear(&ha);
+ header_address_list_clear (&ha);
}
+
return 0;
}
-static char * internet_encode (CamelAddress *a)
+static char *
+internet_encode (CamelAddress *a)
{
int i;
GString *out;
char *ret;
-
+
if (a->addresses->len == 0)
return NULL;
-
- out = g_string_new("");
-
- for (i=0;i<a->addresses->len;i++) {
- struct _address *addr = g_ptr_array_index( a->addresses, i );
- char *name = header_encode_string(addr->name);
-
- if (i!=0)
- g_string_append(out, ", ");
-
+
+ out = g_string_new ("");
+
+ for (i = 0;i < a->addresses->len; i++) {
+ struct _address *addr = g_ptr_array_index (a->addresses, i);
+ char *name = header_encode_string (addr->name);
+
+ if (i != 0)
+ g_string_append (out, ", ");
+
if (name) {
if (*name)
- g_string_sprintfa(out, "%s <%s>", name, addr->address);
+ g_string_sprintfa (out, "\"%s\" <%s>", name, addr->address);
else if (addr->address)
g_string_sprintfa (out, "%s", addr->address);
- g_free(name);
+ g_free (name);
} else
- g_string_sprintfa(out, "%s", addr->address);
+ g_string_sprintfa (out, "%s", addr->address);
}
+
ret = out->str;
- g_string_free(out, FALSE);
+ g_string_free (out, FALSE);
+
return ret;
}
-static void internet_remove (CamelAddress *a, int index)
+static void
+internet_remove (CamelAddress *a, int index)
{
struct _address *addr;
-
- if (index <0 || index >= a->addresses->len)
+
+ if (index < 0 || index >= a->addresses->len)
return;
-
- addr = g_ptr_array_index( a->addresses, index);
- g_free(addr->name);
- g_free(addr->address);
- g_free(addr);
- g_ptr_array_remove_index( a->addresses, index);
+
+ addr = g_ptr_array_index (a->addresses, index);
+ g_free (addr->name);
+ g_free (addr->address);
+ g_free (addr);
+ g_ptr_array_remove_index (a->addresses, index);
}
/**
@@ -154,7 +159,7 @@ static void internet_remove (CamelAddress *a, int index)
CamelInternetAddress *
camel_internet_address_new (void)
{
- CamelInternetAddress *new = CAMEL_INTERNET_ADDRESS ( camel_object_new (camel_internet_address_get_type ()));
+ CamelInternetAddress *new = CAMEL_INTERNET_ADDRESS (camel_object_new (camel_internet_address_get_type ()));
return new;
}