ekiga r7168 - in branches/gnome-2-24: . lib/engine/addressbook/call-history lib/engine/addressbook/ldap lib/engine/framework lib/engine/presence/local-roster



Author: jpuydt
Date: Tue Oct  7 19:42:44 2008
New Revision: 7168
URL: http://svn.gnome.org/viewvc/ekiga?rev=7168&view=rev

Log:
Fixed bug #555226.

Modified:
   branches/gnome-2-24/ChangeLog
   branches/gnome-2-24/lib/engine/addressbook/call-history/history-contact.cpp
   branches/gnome-2-24/lib/engine/addressbook/ldap/ldap-book.cpp
   branches/gnome-2-24/lib/engine/framework/robust-xml.cpp
   branches/gnome-2-24/lib/engine/framework/robust-xml.h
   branches/gnome-2-24/lib/engine/presence/local-roster/local-presentity.cpp

Modified: branches/gnome-2-24/lib/engine/addressbook/call-history/history-contact.cpp
==============================================================================
--- branches/gnome-2-24/lib/engine/addressbook/call-history/history-contact.cpp	(original)
+++ branches/gnome-2-24/lib/engine/addressbook/call-history/history-contact.cpp	Tue Oct  7 19:42:44 2008
@@ -38,6 +38,8 @@
 #include <iostream>
 #include <glib.h>
 
+#include "robust-xml.h"
+
 #include "history-contact.h"
 
 
@@ -112,7 +114,8 @@
 
   xmlSetProp (node, BAD_CAST "uri", BAD_CAST uri.c_str ());
   xmlNewChild (node, NULL,
-	       BAD_CAST "name", BAD_CAST name.c_str ());
+	       BAD_CAST "name",
+	       BAD_CAST robust_xmlEscape (node->doc, name).c_str ());
 
   tmp = g_strdup_printf ("%lu", call_start);
   xmlNewChild (node, NULL,

Modified: branches/gnome-2-24/lib/engine/addressbook/ldap/ldap-book.cpp
==============================================================================
--- branches/gnome-2-24/lib/engine/addressbook/ldap/ldap-book.cpp	(original)
+++ branches/gnome-2-24/lib/engine/addressbook/ldap/ldap-book.cpp	Tue Oct  7 19:42:44 2008
@@ -264,10 +264,14 @@
   node = xmlNewNode (NULL, BAD_CAST "server");
 
   name_node = xmlNewChild (node, NULL,
-			   BAD_CAST "name", BAD_CAST name.c_str ());
+			   BAD_CAST "name",
+			   BAD_CAST robust_xmlEscape (node->doc,
+						      name).c_str ());
 
   hostname_node = xmlNewChild (node, NULL,
-			       BAD_CAST "hostname", BAD_CAST hostname.c_str ());
+			       BAD_CAST "hostname",
+			       BAD_CAST robust_xmlEscape (node->doc,
+							  hostname).c_str ());
 
   { // Snark hates C++ -- and there isn't only a reason for it -- but many
     std::stringstream strm;
@@ -280,18 +284,24 @@
   }
 
   base_node = xmlNewChild (node, NULL,
-			   BAD_CAST "base", BAD_CAST base.c_str ());
+			   BAD_CAST "base",
+			   BAD_CAST robust_xmlEscape (node->doc,
+						      base).c_str ());
 
   scope_node = xmlNewChild (node, NULL,
-			    BAD_CAST "scope", BAD_CAST scope.c_str ());
+			    BAD_CAST "scope",
+			    BAD_CAST robust_xmlEscape (node->doc,
+						       scope).c_str ());
 
   call_attribute_node = xmlNewChild (node, NULL,
 				     BAD_CAST "call_attribute",
-				     BAD_CAST call_attribute.c_str ());
+				     BAD_CAST robust_xmlEscape (node->doc,
+								call_attribute).c_str ());
 
   password_node = xmlNewChild (node, NULL,
 			       BAD_CAST "password",
-			       BAD_CAST password.c_str ());
+			       BAD_CAST robust_xmlEscape (node->doc,
+							  password).c_str ());
 }
 
 OPENLDAP::Book::~Book ()

Modified: branches/gnome-2-24/lib/engine/framework/robust-xml.cpp
==============================================================================
--- branches/gnome-2-24/lib/engine/framework/robust-xml.cpp	(original)
+++ branches/gnome-2-24/lib/engine/framework/robust-xml.cpp	Tue Oct  7 19:42:44 2008
@@ -35,6 +35,20 @@
 
 #include "robust-xml.h"
 
+std::string
+robust_xmlEscape (xmlDocPtr doc,
+		  const std::string& value)
+{
+  xmlChar* escaped =  xmlEncodeEntitiesReentrant (doc,
+						  BAD_CAST value.c_str ());
+
+  std::string result((const char*)escaped);
+
+  xmlFree (escaped);
+
+  return result;
+}
+
 void
 robust_xmlNodeSetContent (xmlNodePtr parent,
 			  xmlNodePtr* child,
@@ -45,10 +59,11 @@
 
     *child = xmlNewChild (parent, NULL,
 			  BAD_CAST name.c_str (),
-			  BAD_CAST value.c_str ());
+			  BAD_CAST robust_xmlEscape (parent->doc,
+						     value).c_str ());
   } else {
 
-    xmlNodeSetContent (*child, xmlEncodeSpecialChars ((*child)->doc,
-						      BAD_CAST value.c_str ()));
+    xmlNodeSetContent (*child, BAD_CAST robust_xmlEscape (parent->doc,
+							  value).c_str ());
   }
 }

Modified: branches/gnome-2-24/lib/engine/framework/robust-xml.h
==============================================================================
--- branches/gnome-2-24/lib/engine/framework/robust-xml.h	(original)
+++ branches/gnome-2-24/lib/engine/framework/robust-xml.h	Tue Oct  7 19:42:44 2008
@@ -39,6 +39,13 @@
 #include <string>
 #include <libxml/tree.h>
 
+/* Returns a correctly escaped string for use as a node content
+ * @param doc The doc for which the string is meant
+ * @param value The raw string to escape
+ */
+std::string robust_xmlEscape (xmlDocPtr doc,
+			      const std::string& value);
+
 /* Sets the content of a node to a given value, creating the node if needed.
  * @param parent The parent node of the node whose value should be set
  * @param child The node whose value should be set, or NULL if needs creating

Modified: branches/gnome-2-24/lib/engine/presence/local-roster/local-presentity.cpp
==============================================================================
--- branches/gnome-2-24/lib/engine/presence/local-roster/local-presentity.cpp	(original)
+++ branches/gnome-2-24/lib/engine/presence/local-roster/local-presentity.cpp	Tue Oct  7 19:42:44 2008
@@ -109,13 +109,16 @@
   node = xmlNewNode (NULL, BAD_CAST "entry");
   xmlSetProp (node, BAD_CAST "uri", BAD_CAST uri.c_str ());
   name_node = xmlNewChild (node, NULL,
-			   BAD_CAST "name", BAD_CAST name.c_str ());
+			   BAD_CAST "name",
+			   BAD_CAST robust_xmlEscape (node->doc,
+						      name).c_str ());
   for (std::set<std::string>::const_iterator iter = groups.begin ();
        iter != groups.end ();
        iter++)
     group_nodes[*iter] = xmlNewChild (node, NULL,
 				      BAD_CAST "group",
-				      BAD_CAST iter->c_str ());
+				      BAD_CAST robust_xmlEscape (node->doc,
+								 *iter).c_str ());
 }
 
 
@@ -285,7 +288,7 @@
       if (std::find (groups.begin (), groups.end (), *iter) == groups.end ())
 	future_group_nodes[*iter] = xmlNewChild (node, NULL,
 						 BAD_CAST "group",
-						 BAD_CAST iter->c_str ());
+						 BAD_CAST robust_xmlEscape (node->doc, *iter).c_str ());
     }
 
     // ok, now we know our groups



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