ekiga r7169 - in trunk: . lib/engine/addressbook/call-history lib/engine/addressbook/ldap lib/engine/components/resource-list lib/engine/framework lib/engine/presence/local-roster



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

Log:
Fixed bug #555226.

Modified:
   trunk/ChangeLog
   trunk/lib/engine/addressbook/call-history/history-contact.cpp
   trunk/lib/engine/addressbook/ldap/ldap-book.cpp
   trunk/lib/engine/components/resource-list/rl-heap.cpp
   trunk/lib/engine/framework/robust-xml.cpp
   trunk/lib/engine/framework/robust-xml.h
   trunk/lib/engine/presence/local-roster/local-presentity.cpp

Modified: trunk/lib/engine/addressbook/call-history/history-contact.cpp
==============================================================================
--- trunk/lib/engine/addressbook/call-history/history-contact.cpp	(original)
+++ trunk/lib/engine/addressbook/call-history/history-contact.cpp	Tue Oct  7 19:43:33 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: trunk/lib/engine/addressbook/ldap/ldap-book.cpp
==============================================================================
--- trunk/lib/engine/addressbook/ldap/ldap-book.cpp	(original)
+++ trunk/lib/engine/addressbook/ldap/ldap-book.cpp	Tue Oct  7 19:43:33 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: trunk/lib/engine/components/resource-list/rl-heap.cpp
==============================================================================
--- trunk/lib/engine/components/resource-list/rl-heap.cpp	(original)
+++ trunk/lib/engine/components/resource-list/rl-heap.cpp	Tue Oct  7 19:43:33 2008
@@ -37,10 +37,12 @@
 
 #include "config.h"
 
-#include "rl-heap.h"
-
 #include <iostream>
 
+#include "robust-xml.h"
+
+#include "rl-heap.h"
+
 RL::Heap::Heap (Ekiga::ServiceCore& core_,
 		xmlNodePtr node_):
   core(core_), node(node_), uri(NULL),
@@ -65,7 +67,9 @@
   if (uri == NULL)
     uri = xmlNewChild (node, NULL, BAD_CAST "uri", BAD_CAST "");
   if (name == NULL)
-    name = xmlNewChild (node, NULL, BAD_CAST "name", BAD_CAST (_("Unnamed")));
+    name = xmlNewChild (node, NULL, BAD_CAST "name",
+			BAD_CAST robust_xmlEscape(node->doc,
+						  _("Unnamed")).c_str ());
   if (username == NULL)
     username = xmlNewChild (node, NULL, BAD_CAST "username", BAD_CAST "");
   if (password == NULL)
@@ -83,17 +87,27 @@
 {
   node = xmlNewNode (NULL, BAD_CAST "entry");
   uri = xmlNewChild (node, NULL,
-		     BAD_CAST "uri", BAD_CAST uri_.c_str ());
+		     BAD_CAST "uri",
+		     BAD_CAST robust_xmlEscape (node->doc,
+						uri_).c_str ());
   username = xmlNewChild (node, NULL,
-			  BAD_CAST "username", BAD_CAST username_.c_str ());
+			  BAD_CAST "username",
+			  BAD_CAST robust_xmlEscape (node->doc,
+						     username_).c_str ());
   password = xmlNewChild (node, NULL,
-			  BAD_CAST "password", BAD_CAST password_.c_str ());
+			  BAD_CAST "password",
+			  BAD_CAST robust_xmlEscape (node->doc,
+						     password_).c_str ());
   if ( !name_.empty ())
     name = xmlNewChild (node, NULL,
-			BAD_CAST "name", BAD_CAST name_.c_str ());
+			BAD_CAST "name",
+			BAD_CAST robust_xmlEscape (node->doc,
+						   name_).c_str ());
   else
     name = xmlNewChild (node, NULL,
-			BAD_CAST "name", BAD_CAST _("Unnamed"));
+			BAD_CAST "name",
+			BAD_CAST robust_xmlEscape (node->doc,
+						   _("Unnamed")).c_str ());
   update ();
 }
 

Modified: trunk/lib/engine/framework/robust-xml.cpp
==============================================================================
--- trunk/lib/engine/framework/robust-xml.cpp	(original)
+++ trunk/lib/engine/framework/robust-xml.cpp	Tue Oct  7 19:43:33 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: trunk/lib/engine/framework/robust-xml.h
==============================================================================
--- trunk/lib/engine/framework/robust-xml.h	(original)
+++ trunk/lib/engine/framework/robust-xml.h	Tue Oct  7 19:43:33 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: trunk/lib/engine/presence/local-roster/local-presentity.cpp
==============================================================================
--- trunk/lib/engine/presence/local-roster/local-presentity.cpp	(original)
+++ trunk/lib/engine/presence/local-roster/local-presentity.cpp	Tue Oct  7 19:43:33 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]