From 09164c637b02f964152453bdbe1b1591c39c1f7c Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 23 Jul 2014 15:03:28 -0400 Subject: [PATCH] VS: Encode more content correctly in vcxproj files (#15031) In cmVisualStudio10TargetGenerator, add missing cmVS10EscapeXML calls around paths to source and object files, custom command dependencies and outputs, and platform name/version values. --- Source/cmVisualStudio10TargetGenerator.cxx | 29 ++++++++++++---------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 2429e59ee..567431737 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -343,19 +343,20 @@ void cmVisualStudio10TargetGenerator::Generate() } this->WriteString("", 2); - (*this->BuildFileStream) << this->Platform << "\n"; + (*this->BuildFileStream) << cmVS10EscapeXML(this->Platform) + << "\n"; const char* projLabel = this->Target->GetProperty("PROJECT_LABEL"); if(!projLabel) { projLabel = this->Name.c_str(); } this->WriteString("", 2); - (*this->BuildFileStream) << projLabel << "\n"; + (*this->BuildFileStream) << cmVS10EscapeXML(projLabel) << "\n"; if(const char* targetFrameworkVersion = this->Target->GetProperty( "VS_DOTNET_TARGET_FRAMEWORK_VERSION")) { this->WriteString("", 2); - (*this->BuildFileStream) << targetFrameworkVersion + (*this->BuildFileStream) << cmVS10EscapeXML(targetFrameworkVersion) << "\n"; } this->WriteString("\n", 1); @@ -507,7 +508,8 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurations() this->WriteString("", 3); (*this->BuildFileStream ) << *i << "\n"; this->WriteString("", 3); - (*this->BuildFileStream) << this->Platform << "\n"; + (*this->BuildFileStream) << cmVS10EscapeXML(this->Platform) + << "\n"; this->WriteString("\n", 2); } this->WriteString("\n", 1); @@ -700,7 +702,7 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile const* source, (*this->BuildFileStream ) << script << "\n"; this->WritePlatformConfigTag("AdditionalInputs", i->c_str(), 3); - (*this->BuildFileStream ) << source->GetFullPath(); + (*this->BuildFileStream ) << cmVS10EscapeXML(source->GetFullPath()); for(std::vector::const_iterator d = ccg.GetDepends().begin(); d != ccg.GetDepends().end(); @@ -710,7 +712,7 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile const* source, if(this->LocalGenerator->GetRealDependency(d->c_str(), i->c_str(), dep)) { this->ConvertToWindowsSlash(dep); - (*this->BuildFileStream ) << ";" << dep; + (*this->BuildFileStream ) << ";" << cmVS10EscapeXML(dep); } } (*this->BuildFileStream ) << ";%(AdditionalInputs)\n"; @@ -723,7 +725,7 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile const* source, { std::string out = *o; this->ConvertToWindowsSlash(out); - (*this->BuildFileStream ) << sep << out; + (*this->BuildFileStream ) << sep << cmVS10EscapeXML(out); sep = ";"; } (*this->BuildFileStream ) << "\n"; @@ -824,7 +826,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups() std::string obj = (*oi)->GetFullPath(); this->WriteString("ConvertToWindowsSlash(obj); - (*this->BuildFileStream ) << obj << "\">\n"; + (*this->BuildFileStream ) << cmVS10EscapeXML(obj) << "\">\n"; this->WriteString("Resource Files\n", 3); this->WriteString("\n", 2); } @@ -843,7 +845,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups() std::string obj = *oi; this->WriteString("ConvertToWindowsSlash(obj); - (*this->BuildFileStream ) << obj << "\">\n"; + (*this->BuildFileStream ) << cmVS10EscapeXML(obj) << "\">\n"; this->WriteString("Object Libraries\n", 3); this->WriteString("\n", 2); } @@ -978,7 +980,7 @@ WriteGroupSources(const char* name, std::string path = this->ConvertPath(source, s->RelativePath); this->ConvertToWindowsSlash(path); (*this->BuildFileStream) << name << " Include=\"" - << path; + << cmVS10EscapeXML(path); if(strlen(filter)) { (*this->BuildFileStream) << "\">\n"; @@ -1033,7 +1035,8 @@ void cmVisualStudio10TargetGenerator::WriteSource( } this->ConvertToWindowsSlash(sourceFile); this->WriteString("<", 2); - (*this->BuildFileStream ) << tool << " Include=\"" << sourceFile << "\""; + (*this->BuildFileStream ) << tool << " Include=\"" + << cmVS10EscapeXML(sourceFile) << "\""; if(sf->GetExtension() == "h" && this->IsResxHeader(sf->GetFullPath())) @@ -1165,7 +1168,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() std::string obj = *oi; this->WriteString("ConvertToWindowsSlash(obj); - (*this->BuildFileStream ) << obj << "\" />\n"; + (*this->BuildFileStream ) << cmVS10EscapeXML(obj) << "\" />\n"; } this->WriteString("\n", 1); @@ -2044,7 +2047,7 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences() path += dt->GetName(); path += ".vcxproj"; } - (*this->BuildFileStream) << path << "\">\n"; + (*this->BuildFileStream) << cmVS10EscapeXML(path) << "\">\n"; this->WriteString("", 3); (*this->BuildFileStream) << this->GlobalGenerator->GetGUID(name.c_str())