From 5ebcb51fb4b3f4ad6ce6933e3f166d3824cf9154 Mon Sep 17 00:00:00 2001 From: Andy Cedilnik Date: Wed, 2 Apr 2003 09:19:45 -0500 Subject: [PATCH] Url escape password --- Source/cmCTest.cxx | 33 ++++++++++++++++++++++++++++++--- Source/cmCTest.h | 1 + 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 858ef413a..3ee80e904 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -188,6 +188,33 @@ std::string cmCTest::MakeXMLSafe(const std::string& str) return ost.str(); } +std::string cmCTest::MakeURLSafe(const std::string& str) +{ + std::string::size_type pos = 0; + cmOStringStream ost; + char buffer[10]; + for ( pos = 0; pos < str.size(); pos ++ ) + { + unsigned char ch = str[pos]; + if ( ( ch > 126 || ch < 32 || + ch == '&' || + ch == '%' || + ch == '+' || + ch == '=' || + ch == '@' + ) && ch != 9 ) + { + sprintf(buffer, "%02x;", (unsigned int)ch); + ost << buffer; + } + else + { + ost << ch; + } + } + return ost.str(); +} + bool TryExecutable(const char *dir, const char *file, std::string *fullPath, const char *subdir) { @@ -1831,10 +1858,10 @@ int cmCTest::SubmitResults() { std::cout << "FTP submit method" << std::endl; std::string url = "ftp://"; - url += m_DartConfiguration["DropSiteUser"] + ":" + - m_DartConfiguration["DropSitePassword"] + "@" + + url += cmCTest::MakeURLSafe(m_DartConfiguration["DropSiteUser"]) + ":" + + cmCTest::MakeURLSafe(m_DartConfiguration["DropSitePassword"]) + "@" + m_DartConfiguration["DropSite"] + - m_DartConfiguration["DropLocation"]; + cmCTest::MakeURLSafe(m_DartConfiguration["DropLocation"]); if ( !submit.SubmitUsingFTP(m_ToplevelPath+"/Testing/"+m_CurrentTag, files, prefix, url) ) { diff --git a/Source/cmCTest.h b/Source/cmCTest.h index 7f81aea62..5e252c3ef 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -216,6 +216,7 @@ private: bool OpenOutputFile(const std::string& path, const std::string& name, std::ofstream& stream); std::string MakeXMLSafe(const std::string&); + std::string MakeURLSafe(const std::string&); }; #endif