[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.32, 1.32.2.1 xml_fi
From: |
address@hidden |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src xml_helper.cxx, 1.32, 1.32.2.1 xml_file_writer.cxx, 1.4, 1.4.2.1 |
Date: |
Wed, 31 Mar 2004 20:14:50 +0200 |
Update of /var/lib/cvs/Games/Pingus/src
In directory dark:/tmp/cvs-serv7339
Modified Files:
Tag: pingus_0_6
xml_helper.cxx xml_file_writer.cxx
Log Message:
make xml special char handling a little bit better
Index: xml_helper.cxx
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/src/xml_helper.cxx,v
retrieving revision 1.32
retrieving revision 1.32.2.1
diff -u -d -r1.32 -r1.32.2.1
--- xml_helper.cxx 24 Apr 2003 17:59:15 -0000 1.32
+++ xml_helper.cxx 31 Mar 2004 18:14:48 -0000 1.32.2.1
@@ -155,21 +155,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;
}
Index: xml_file_writer.cxx
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/src/xml_file_writer.cxx,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -u -d -r1.4 -r1.4.2.1
--- xml_file_writer.cxx 19 Apr 2003 10:23:17 -0000 1.4
+++ xml_file_writer.cxx 31 Mar 2004 18:14:48 -0000 1.4.2.1
@@ -21,6 +21,7 @@
#include "vector.hxx"
#include "color.hxx"
#include "xml_file_writer.hxx"
+#include "xml_helper.hxx"
XMLFileWriter::XMLFileWriter(std::ostream& out_)
: out(&out_)
@@ -89,9 +90,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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src xml_helper.cxx, 1.32, 1.32.2.1 xml_file_writer.cxx, 1.4, 1.4.2.1,
address@hidden <=