[gnome-contacts: 7/8] Properly escape strings passed to set_markup



commit 6de39ca105da77e61e250d8dbcb1b7c027161144
Author: Alexander Larsson <alexl redhat com>
Date:   Mon May 14 11:58:45 2012 +0200

    Properly escape strings passed to set_markup

 src/contacts-avatar-dialog.vala |    2 +-
 src/contacts-contact-pane.vala  |   14 +++++++-------
 src/contacts-contact.vala       |    2 +-
 src/contacts-link-dialog.vala   |    6 +++---
 src/contacts-setup-window.vala  |    2 +-
 src/contacts-view.vala          |    2 +-
 6 files changed, 14 insertions(+), 14 deletions(-)
---
diff --git a/src/contacts-avatar-dialog.vala b/src/contacts-avatar-dialog.vala
index dce0f4a..1b46aab 100644
--- a/src/contacts-avatar-dialog.vala
+++ b/src/contacts-avatar-dialog.vala
@@ -266,7 +266,7 @@ public class Contacts.AvatarDialog : Dialog {
     grid.attach (main_frame, 0, 0, 1, 1);
 
     var label = new Label ("");
-    label.set_markup ("<span font='16'>" + contact.display_name + "</span>");
+    label.set_markup (Markup.printf_escaped ("<span font='16'>%s</span>", contact.display_name));
     label.set_valign (Align.START);
     label.set_halign (Align.START);
     label.set_hexpand (true);
diff --git a/src/contacts-contact-pane.vala b/src/contacts-contact-pane.vala
index 2a5526a..2b7ff6a 100644
--- a/src/contacts-contact-pane.vala
+++ b/src/contacts-contact-pane.vala
@@ -204,7 +204,7 @@ public class Contacts.FieldRow : Contacts.Row {
   public void pack_header (string s) {
     var l = new Label (s);
     l.set_markup (
-      "<span font='24px'>%s</span>".printf (s));
+      Markup.printf_escaped ("<span font='24px'>%s</span>", s));
     l.set_halign (Align.START);
     pack (l);
   }
@@ -215,7 +215,7 @@ public class Contacts.FieldRow : Contacts.Row {
     var l = new Label (s);
     label = l;
     l.set_markup (
-      "<span font='24px'>%s</span>".printf (s));
+      Markup.printf_escaped ("<span font='24px'>%s</span>", s));
     l.set_halign (Align.START);
     l.set_hexpand (true);
 
@@ -1552,7 +1552,7 @@ public class Contacts.ContactPane : ScrolledWindow {
     l.xalign = 0.0f;
 
     contact.keep_widget_uptodate (l,  (w) => {
-	(w as Label).set_markup ("<span font='16'>" + contact.display_name + "</span>");
+	(w as Label).set_markup (Markup.printf_escaped ("<span font='16'>%s</span>", contact.display_name));
       });
 
     var event_box = new EventBox ();
@@ -1609,7 +1609,7 @@ public class Contacts.ContactPane : ScrolledWindow {
 	if (save && changed) {
 	  // Things look better if we update immediately, rather than after the setting has
 	  // been applied
-	  l.set_markup ("<span font='16'>" + entry.get_text () + "</span>");
+	  l.set_markup (Markup.printf_escaped ("<span font='16'>%s</span>", entry.get_text ()));
 
 	  Value v = Value (typeof (string));
 	  v.set_string (entry.get_text ());
@@ -1620,7 +1620,7 @@ public class Contacts.ContactPane : ScrolledWindow {
 					     set_individual_property.end (result);
 					   } catch (Error e) {
 					     App.app.show_message (e.message);
-					     l.set_markup ("<span font='16'>" + contact.display_name + "</span>");
+					     l.set_markup (Markup.printf_escaped ("<span font='16'>%s</span>", contact.display_name));
 					   }
 					 });
 	}
@@ -1763,9 +1763,9 @@ public class Contacts.ContactPane : ScrolledWindow {
 
     var label = new Label ("");
     if (contact.is_main)
-      label.set_markup (_("Does %s from %s belong here?").printf (c.display_name, c.format_persona_stores ()));
+      label.set_markup (Markup.printf_escaped (_("Does %s from %s belong here?"), c.display_name, c.format_persona_stores ()));
     else
-      label.set_markup (_("Do these details belong to %s?").printf (c.display_name));
+      label.set_markup (Markup.printf_escaped (_("Do these details belong to %s?"), c.display_name));
     label.set_valign (Align.START);
     label.set_halign (Align.START);
     label.set_line_wrap (true);
diff --git a/src/contacts-contact.vala b/src/contacts-contact.vala
index 9a2f52f..695edc5 100644
--- a/src/contacts-contact.vala
+++ b/src/contacts-contact.vala
@@ -65,7 +65,7 @@ public class Contacts.ContactPresence : Grid {
     if (message.length == 0)
       message = Contact.presence_to_string (type);
 
-    label.set_markup ("<span font='11px'>" + message + "</span>");
+    label.set_markup (Markup.printf_escaped ("<span font='11px'>%s</span>", message));
     label.set_margin_bottom (3);
 
     if (is_phone)
diff --git a/src/contacts-link-dialog.vala b/src/contacts-link-dialog.vala
index 7024168..cefec4e 100644
--- a/src/contacts-link-dialog.vala
+++ b/src/contacts-link-dialog.vala
@@ -52,7 +52,7 @@ public class Contacts.LinkDialog : Dialog {
     persona_grid.attach (image_frame, 0, 0, 1, 2);
 
     var label = new Label ("");
-    label.set_markup ("<span font='13'>" + selected_contact.display_name + "</span>");
+    label.set_markup (Markup.printf_escaped ("<span font='13'>%s</span>", selected_contact.display_name));
     label.set_valign (Align.START);
     label.set_halign (Align.START);
     label.set_hexpand (false);
@@ -61,7 +61,7 @@ public class Contacts.LinkDialog : Dialog {
     persona_grid.attach (label, 1, 0, 1, 1);
 
     label = new Label ("");
-    label.set_markup ("<span font='9'>" +selected_contact.format_persona_stores () + "</span>");
+    label.set_markup (Markup.printf_escaped ("<span font='9'>%s</span>", selected_contact.format_persona_stores ()));
     label.set_valign (Align.START);
     label.set_halign (Align.START);
     label.set_hexpand (true);
@@ -179,7 +179,7 @@ public class Contacts.LinkDialog : Dialog {
 
     var label = new Label ("");
     if (contact.is_main)
-      label.set_markup (_("<span weight='bold'>Link contacts to %s</span>").printf (contact.display_name));
+      label.set_markup (Markup.printf_escaped (_("<span weight='bold'>Link contacts to %s</span>"), contact.display_name));
     else
       label.set_markup (_("<span weight='bold'>Select contact to link to</span>"));
     label.set_valign (Align.CENTER);
diff --git a/src/contacts-setup-window.vala b/src/contacts-setup-window.vala
index 0ccd9cb..359b987 100644
--- a/src/contacts-setup-window.vala
+++ b/src/contacts-setup-window.vala
@@ -147,7 +147,7 @@ public class Contacts.SetupWindow : Gtk.Window {
 
     var item = new ToolItem ();
     title_label = new Label ("");
-    title_label.set_markup ("<b>%s</b>".printf (_("Contacts Setup")));
+    title_label.set_markup (Markup.printf_escaped ("<b>%s</b>",_("Contacts Setup")));
     title_label.set_no_show_all (true);
     item.add (title_label);
     item.set_expand (true);
diff --git a/src/contacts-view.vala b/src/contacts-view.vala
index 3eec896..072611f 100644
--- a/src/contacts-view.vala
+++ b/src/contacts-view.vala
@@ -174,7 +174,7 @@ public class Contacts.View : Egg.ListBox {
     data.initial_letter = c.initial_letter;
     data.filtered = calculate_filtered (c);
 
-    data.label.set_markup ("<span font='16px'>" + data.display_name + "</span>");
+    data.label.set_markup (Markup.printf_escaped ("<span font='16px'>%s</span>", data.display_name));
     data.image_frame.set_image (c.individual, c);
   }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]