Forráskód Böngészése

2009-06-06 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

	Use htmlEscape instead of xmlEscape. Removed static function xmlEscape.
	* src/XmlRpcResponse.cc
Tatsuhiro Tsujikawa 16 éve
szülő
commit
f36ef2d26d
2 módosított fájl, 9 hozzáadás és 19 törlés
  1. 5 0
      ChangeLog
  2. 4 19
      src/XmlRpcResponse.cc

+ 5 - 0
ChangeLog

@@ -1,3 +1,8 @@
+2009-06-06  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
+
+	Use htmlEscape instead of xmlEscape. Removed static function xmlEscape.
+	* src/XmlRpcResponse.cc
+
 2009-06-06  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
 
 	Avoid intermediate object during string concatenation.

+ 4 - 19
src/XmlRpcResponse.cc

@@ -37,27 +37,12 @@
 #include <cassert>
 #include <sstream>
 
+#include "Util.h"
+
 namespace aria2 {
 
 namespace xmlrpc {
 
-static std::string xmlEscape(const std::string& s)
-{
-  std::string d;
-  for(std::string::const_iterator i = s.begin(); i != s.end(); ++i) {
-    if(*i == '<') {
-      d += "&lt;";
-    } else if(*i == '>') {
-      d += "&gt;";
-    } else if(*i == '&') {
-      d += "&amp;";
-    } else {
-      d += *i;
-    }
-  }
-  return d;
-}
-
 static void encodeValue(const BDE& value, std::ostream& o);
 
 template<typename InputIterator>
@@ -78,7 +63,7 @@ static void encodeStruct
   o << "<struct>";
   for(; first != last; ++first) {
     o << "<member>"
-      << "<name>" << xmlEscape((*first).first) << "</name>";
+      << "<name>" << Util::htmlEscape((*first).first) << "</name>";
     encodeValue((*first).second, o);
     o << "</member>";
   }
@@ -89,7 +74,7 @@ static void encodeValue(const BDE& value, std::ostream& o)
 {
   o << "<value>";
   if(value.isString()) {
-    o << "<string>" << xmlEscape(value.s()) << "</string>";
+    o << "<string>" << Util::htmlEscape(value.s()) << "</string>";
   } else if(value.isInteger()) {
     o << "<int>" << value.i() << "</int>";
   } else if(value.isList()) {