[folks] eds: Ignore empty values when creating AbstractFieldDetails instances
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks] eds: Ignore empty values when creating AbstractFieldDetails instances
- Date: Sun, 25 Dec 2011 11:00:26 +0000 (UTC)
commit dd743bdc54c477a8e5653b4e00d569b151199365
Author: Philip Withnall <philip tecnocode co uk>
Date: Wed Dec 21 20:08:32 2011 +0000
eds: Ignore empty values when creating AbstractFieldDetails instances
We don't want to be passing around (e.g.) empty strings as e-mail addresses,
or we'll cause bugs like bgo#666540.
This modifies the EDS backend to check E.VCardAttribute.get_value() is not
null or the empty string whenever it's called, and skip the attribute as
appropriate.
Helps: bgo#666540
backends/eds/lib/edsf-persona.vala | 48 ++++++++++++++++++++++++++++++-----
1 files changed, 41 insertions(+), 7 deletions(-)
---
diff --git a/backends/eds/lib/edsf-persona.vala b/backends/eds/lib/edsf-persona.vala
index a295b8d..8d68b0b 100644
--- a/backends/eds/lib/edsf-persona.vala
+++ b/backends/eds/lib/edsf-persona.vala
@@ -941,8 +941,14 @@ public class Edsf.Persona : Folks.Persona,
if (attr.get_name () != "X-ROLES")
continue;
+ var val = attr.get_value ();
+ if (val == null || val == "")
+ {
+ continue;
+ }
+
var role = new Role ("", "");
- role.role = attr.get_value ();
+ role.role = val;
var role_fd = new RoleFieldDetails (role);
foreach (unowned E.VCardAttributeParam param in
@@ -1046,8 +1052,10 @@ public class Edsf.Persona : Folks.Persona,
var service_name = service.get_name ().down ();
foreach (var service_id in service.get_values ())
{
- if (service_id == null)
- continue;
+ if (service_id == null || service_id == "")
+ {
+ continue;
+ }
new_services.set (service_name,
new WebServiceFieldDetails (service_id));
@@ -1072,7 +1080,13 @@ public class Edsf.Persona : Folks.Persona,
var attrs = this.contact.get_attributes (E.ContactField.EMAIL);
foreach (var attr in attrs)
{
- var email_fd = new EmailFieldDetails (attr.get_value ());
+ var val = attr.get_value ();
+ if (val == null || val == "")
+ {
+ continue;
+ }
+
+ var email_fd = new EmailFieldDetails (val);
this._update_params (email_fd, attr);
new_email_addresses.add (email_fd);
}
@@ -1261,7 +1275,13 @@ public class Edsf.Persona : Folks.Persona,
{
if (attr.get_name () == "X-URIS")
{
- var url_fd = new UrlFieldDetails (attr.get_value ());
+ var val = attr.get_value ();
+ if (val == null || val == "")
+ {
+ continue;
+ }
+
+ var url_fd = new UrlFieldDetails (val);
this._update_params (url_fd, attr);
new_urls.add (url_fd);
}
@@ -1291,6 +1311,11 @@ public class Edsf.Persona : Folks.Persona,
try
{
var addr = attr.get_value ();
+ if (addr == null || addr == "")
+ {
+ continue;
+ }
+
string normalised_addr =
(owned) ImDetails.normalise_im_address (addr, im_proto);
var im_fd = new ImFieldDetails (normalised_addr);
@@ -1450,7 +1475,13 @@ public class Edsf.Persona : Folks.Persona,
var attrs = this.contact.get_attributes (E.ContactField.TEL);
foreach (var attr in attrs)
{
- var phone_fd = new PhoneFieldDetails (attr.get_value ());
+ var val = attr.get_value ();
+ if (val == null || val == "")
+ {
+ continue;
+ }
+
+ var phone_fd = new PhoneFieldDetails (val);
this._update_params (phone_fd, attr);
new_phone_numbers.add (phone_fd);
}
@@ -1562,7 +1593,10 @@ public class Edsf.Persona : Folks.Persona,
foreach (var local_id in ids_v)
{
- new_local_ids.add (local_id);
+ if (local_id != null && local_id != "")
+ {
+ new_local_ids.add (local_id);
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]