From cf0ab29fcb7edb67488da8498e3e1e68a48e5ca7 Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Thu, 8 Jan 2009 18:09:50 -0500 Subject: [PATCH] BUG: apply patch from #8205, also fixes #8212: escape characters for XML when writing the eclipse project files Alex --- Source/cmExtraEclipseCDT4Generator.cxx | 16 +++++++++++++++- Source/cmExtraEclipseCDT4Generator.h | 2 ++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index d04ee73ebe..713aeb939a 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -573,7 +573,8 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const { emmited.insert(def); fout << "\n"; + << "\" path=\"\" value=\"" << this->EscapeForXML(val) + << "\"/>\n"; } } } @@ -792,6 +793,19 @@ cmExtraEclipseCDT4Generator::GenerateProjectName(const std::string& name, return name + (type.empty() ? "" : "-") + type + "@" + path; } +std::string cmExtraEclipseCDT4Generator::EscapeForXML(const std::string& value) +{ + std::string str = value; + cmSystemTools::ReplaceString(str, "&", "&"); + cmSystemTools::ReplaceString(str, "<", "<"); + cmSystemTools::ReplaceString(str, ">", ">"); + cmSystemTools::ReplaceString(str, "\"", """); + // NOTE: This one is not necessary, since as of Eclipse CDT4 it will + // automatically change this to the original value ('). + //cmSystemTools::ReplaceString(str, "'", "'"); + return str; +} + //---------------------------------------------------------------------------- // Helper functions //---------------------------------------------------------------------------- diff --git a/Source/cmExtraEclipseCDT4Generator.h b/Source/cmExtraEclipseCDT4Generator.h index aa9da23e10..349156a34d 100644 --- a/Source/cmExtraEclipseCDT4Generator.h +++ b/Source/cmExtraEclipseCDT4Generator.h @@ -84,6 +84,8 @@ private: const std::string& type, const std::string& path); + static std::string EscapeForXML(const std::string& value); + // Helper functions static void AppendStorageScanners(cmGeneratedFileStream& fout); static void AppendTarget (cmGeneratedFileStream& fout,