[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src xml_helper.cxx, 1.33, 1.34 xml_file_w
From: |
address@hidden |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src xml_helper.cxx, 1.33, 1.34 xml_file_writer.cxx, 1.5, 1.6 |
Date: |
Wed, 31 Mar 2004 20:17:40 +0200 |
Update of /var/lib/cvs/Games/Pingus/src
In directory dark:/tmp/cvs-serv8298
Modified Files:
xml_helper.cxx xml_file_writer.cxx
Log Message:
make xml special character handling a little bit better
Index: xml_helper.cxx
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/src/xml_helper.cxx,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- xml_helper.cxx 18 Oct 2003 23:17:27 -0000 1.33
+++ xml_helper.cxx 31 Mar 2004 18:17:38 -0000 1.34
@@ -30,6 +30,8 @@
int xmlIsBlankNode(xmlNodePtr node) { return 0; }
#endif
+namespace Pingus {
+
std::ostream& operator<<(std::ostream& s, xmlNode& node)
{
#if LIBXML_VERSION >= 20506
@@ -50,8 +52,6 @@
#endif
}
-namespace Pingus {
-
xmlNodePtr
XMLhelper::skip_blank (xmlNodePtr cur)
{
@@ -157,21 +157,21 @@
std::string
XMLhelper::encode_entities (const std::string& arg_str)
{
- ///xmlEncodeEntitiesReentrant()
- std::string str = arg_str;
- std::string::size_type i;
- // std::cout << "encode_xml: " << str << std::endl;
-
- i = str.find("<");
- if (i != std::string::npos)
- str.replace(i, 1, "<");
-
- i = str.find(">");
- if (i != std::string::npos)
- str.replace(i, 1, ">");
-
- // std::cout << "encode_xml-done: " << str << std::endl;
-
+ //xmlEncodeEntitiesReentrant()
+ std::string str;
+ for (unsigned int i=0; i < arg_str.size(); ++i)
+ {
+ switch (arg_str[i])
+ {
+ case '\'': str += "'"; break;
+ case '"' : str += """; break;
+ case '<' : str += "<" ; break;
+ case '>' : str += ">" ; break;
+ case '&' : str += "&" ; break;
+ default: str += arg_str[i];
+ }
+ }
+
return str;
}
@@ -492,5 +492,4 @@
}
} // namespace Pingus
-
/* EOF */
Index: xml_file_writer.cxx
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/src/xml_file_writer.cxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- xml_file_writer.cxx 18 Oct 2003 23:17:27 -0000 1.5
+++ xml_file_writer.cxx 31 Mar 2004 18:17:38 -0000 1.6
@@ -21,6 +21,7 @@
#include "vector.hxx"
#include "color.hxx"
#include "xml_file_writer.hxx"
+#include "xml_helper.hxx"
namespace Pingus {
@@ -91,9 +92,7 @@
void
XMLFileWriter::write_string (const char* name, const std::string& value)
{
- // FIXME: We don't handle escaping of characters here, might end
- // FIXME: ugly if people enter '<>' in there strings.
- (*out) << "<" << name << ">" << value << "</" << name << ">\n";
+ (*out) << "<" << name << ">" << XMLhelper::encode_entities(value) << "</" <<
name << ">\n";
}
void
@@ -107,5 +106,4 @@
}
} // namespace Pingus
-
/* EOF */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src xml_helper.cxx, 1.33, 1.34 xml_file_writer.cxx, 1.5, 1.6,
address@hidden <=