From 1f376290a2ae1383a308d31d0a2d12bbc7eb8020 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Sun, 18 Sep 2005 19:01:25 +0000 Subject: [PATCH] Always escape quotes in XML files. --- src/common/common.cpp | 7 +++---- src/common/common.h | 2 +- src/common/xml_element_writer.cpp | 8 ++++---- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/common/common.cpp b/src/common/common.cpp index f448b3613..760b3597a 100644 --- a/src/common/common.cpp +++ b/src/common/common.cpp @@ -901,8 +901,7 @@ unescape(const string &source) { } string -escape_xml(const string &source, - bool escape_quotes) { +escape_xml(const string &source) { string dst; string::const_iterator src; @@ -914,7 +913,7 @@ escape_xml(const string &source, dst += ">"; else if (*src == '<') dst += "<"; - else if (escape_quotes && (*src == '"')) + else if (*src == '"') dst += """; else dst += *src; @@ -933,7 +932,7 @@ create_xml_node_name(const char *name, node_name = string("<") + name; for (i = 0; (NULL != atts[i]) && (NULL != atts[i + 1]); i += 2) node_name += string(" ") + atts[i] + "=\"" + - escape_xml(atts[i + 1], true) + "\""; + escape_xml(atts[i + 1]) + "\""; node_name += ">"; return node_name; diff --git a/src/common/common.h b/src/common/common.h index 55c1ca92e..b89813dce 100644 --- a/src/common/common.h +++ b/src/common/common.h @@ -238,7 +238,7 @@ void MTX_DLL_API strip(string &s, bool newlines = false); void MTX_DLL_API strip(vector &v, bool newlines = false); string MTX_DLL_API escape(const string &src); string MTX_DLL_API unescape(const string &src); -string MTX_DLL_API escape_xml(const string &src, bool escape_quotes = false); +string MTX_DLL_API escape_xml(const string &src); string MTX_DLL_API create_xml_node_name(const char *name, const char **atts); bool MTX_DLL_API starts_with(const string &s, const char *start, int maxlen = -1); diff --git a/src/common/xml_element_writer.cpp b/src/common/xml_element_writer.cpp index f61b0b756..1d4ec1cb5 100644 --- a/src/common/xml_element_writer.cpp +++ b/src/common/xml_element_writer.cpp @@ -214,14 +214,14 @@ xml_formatter_c::write_header() { #endif m_out->write_bom(m_encoding); m_out->printf("\n", - escape_xml(m_encoding, true).c_str()); + escape_xml(m_encoding).c_str()); if ((m_dtd != "") && (m_dtd_file != "")) m_out->printf("\n\n", m_dtd.c_str(), - escape_xml(m_dtd_file, true).c_str()); + escape_xml(m_dtd_file).c_str()); if ((m_stylesheet_type != "") && (m_stylesheet_file != "")) m_out->printf("\n\n", - escape_xml(m_stylesheet_type, true).c_str(), - escape_xml(m_stylesheet_file, true).c_str()); + escape_xml(m_stylesheet_type).c_str(), + escape_xml(m_stylesheet_file).c_str()); m_header_written = true; }