aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/util
diff options
context:
space:
mode:
authorChris Toshok <toshok@ximian.com>2004-01-27 01:03:22 +0800
committerChris Toshok <toshok@src.gnome.org>2004-01-27 01:03:22 +0800
commit06ae1bac42c987d3592883cceb55eaaa1be2514f (patch)
treece47b56839e645e38be9201157355ff3aac4103a /addressbook/util
parent3bb08252f25f0125ae53f9943b3e9898220ae735 (diff)
downloadgsoc2013-evolution-06ae1bac42c987d3592883cceb55eaaa1be2514f.tar
gsoc2013-evolution-06ae1bac42c987d3592883cceb55eaaa1be2514f.tar.gz
gsoc2013-evolution-06ae1bac42c987d3592883cceb55eaaa1be2514f.tar.bz2
gsoc2013-evolution-06ae1bac42c987d3592883cceb55eaaa1be2514f.tar.lz
gsoc2013-evolution-06ae1bac42c987d3592883cceb55eaaa1be2514f.tar.xz
gsoc2013-evolution-06ae1bac42c987d3592883cceb55eaaa1be2514f.tar.zst
gsoc2013-evolution-06ae1bac42c987d3592883cceb55eaaa1be2514f.zip
[ fixes #53238 ] make this accept NULL's (and return FALSE for them).
2004-01-26 Chris Toshok <toshok@ximian.com> [ fixes #53238 ] * util/eab-destination.c (nonempty): make this accept NULL's (and return FALSE for them). (eab_destination_is_empty): shorten some of the tests since nonempty takes NULL now. (eab_destination_get_address): only call camel_internet_address_add if both name and email are non-empty. otherwise call camel_address_decode and let camel try to deal with it. (eab_destination_xml_encode): call xmlEncodeEntitiesReentrant on the strings before adding them to the xml, so people that enter [<>&] won't end up with broken EABDestinations. svn path=/trunk/; revision=24439
Diffstat (limited to 'addressbook/util')
-rw-r--r--addressbook/util/eab-destination.c54
1 files changed, 40 insertions, 14 deletions
diff --git a/addressbook/util/eab-destination.c b/addressbook/util/eab-destination.c
index 07557b1455..020a9a5e09 100644
--- a/addressbook/util/eab-destination.c
+++ b/addressbook/util/eab-destination.c
@@ -310,6 +310,8 @@ static gboolean
nonempty (const gchar *s)
{
gunichar c;
+ if (s == NULL)
+ return FALSE;
while (*s) {
c = g_utf8_get_char (s);
if (!g_unichar_isspace (c))
@@ -332,10 +334,10 @@ eab_destination_is_empty (const EABDestination *dest)
return !(p->contact != NULL
|| (p->book_uri && *p->book_uri)
|| (p->uid && *p->uid)
- || (p->raw && nonempty (p->raw))
- || (p->name && nonempty (p->name))
- || (p->email && nonempty (p->email))
- || (p->addr && nonempty (p->addr))
+ || (nonempty (p->raw))
+ || (nonempty (p->name))
+ || (nonempty (p->email))
+ || (nonempty (p->addr))
|| (p->list_dests != NULL));
}
@@ -757,9 +759,17 @@ eab_destination_get_address (const EABDestination *dest)
EABDestination *list_dest = EAB_DESTINATION (iter->data);
if (!eab_destination_is_empty (list_dest)) {
- camel_internet_address_add (addr,
- eab_destination_get_name (list_dest),
- eab_destination_get_email (list_dest));
+ const char *name, *email;
+ name = eab_destination_get_name (list_dest);
+ email = eab_destination_get_email (list_dest);
+
+ if (nonempty (name) && nonempty (email))
+ camel_internet_address_add (addr, name, email);
+ else if (nonempty (email))
+ camel_address_decode (CAMEL_ADDRESS (addr), email);
+ else /* this case loses i suppose, but there's
+ nothing we can do here */
+ camel_address_decode (CAMEL_ADDRESS (addr), name);
}
iter = g_list_next (iter);
}
@@ -771,9 +781,17 @@ eab_destination_get_address (const EABDestination *dest)
priv->addr = camel_address_encode (CAMEL_ADDRESS (addr));
}
} else {
- camel_internet_address_add (addr,
- eab_destination_get_name (dest),
- eab_destination_get_email (dest));
+ const char *name, *email;
+ name = eab_destination_get_name (dest);
+ email = eab_destination_get_email (dest);
+
+ if (nonempty (name) && nonempty (email))
+ camel_internet_address_add (addr, name, email);
+ else if (nonempty (email))
+ camel_address_decode (CAMEL_ADDRESS (addr), email);
+ else /* this case loses i suppose, but there's
+ nothing we can do here */
+ camel_address_decode (CAMEL_ADDRESS (addr), name);
priv->addr = camel_address_encode (CAMEL_ADDRESS (addr));
}
@@ -1136,14 +1154,20 @@ eab_destination_xml_encode (const EABDestination *dest)
while (iter) {
EABDestination *list_dest = EAB_DESTINATION (iter->data);
xmlNodePtr list_node = xmlNewNode (NULL, "list_entry");
-
+
str = eab_destination_get_name (list_dest);
- if (str)
- xmlNewTextChild (list_node, NULL, "name", str);
+ if (str) {
+ char *escaped = xmlEncodeEntitiesReentrant (NULL, str);
+ xmlNewTextChild (list_node, NULL, "name", escaped);
+ xmlFree (escaped);
+ }
str = eab_destination_get_email (list_dest);
- if (str)
+ if (str) {
+ char *escaped = xmlEncodeEntitiesReentrant (NULL, str);
xmlNewTextChild (list_node, NULL, "email", str);
+ xmlFree (escaped);
+ }
xmlAddChild (dest_node, list_node);
@@ -1157,7 +1181,9 @@ eab_destination_xml_encode (const EABDestination *dest)
str = eab_destination_get_book_uri (dest);
if (str) {
+ char *escaped = xmlEncodeEntitiesReentrant (NULL, str);
xmlNewTextChild (dest_node, NULL, "book_uri", str);
+ xmlFree (escaped);
}
str = eab_destination_get_contact_uid (dest);