Url Encode SMS messages.

This commit is contained in:
Arthur Britto
2013-03-30 01:00:00 -07:00
parent 58b3cc1dd6
commit c67366ea25
3 changed files with 37 additions and 3 deletions

View File

@@ -473,7 +473,7 @@ void HttpsClient::sendSMS(boost::asio::io_service& io_service, const std::string
% theConfig.SMS_TO
% theConfig.SMS_KEY
% theConfig.SMS_SECRET
% strText);
% urlEncode(strText));
// cLog(lsINFO) << "SMS: Request:" << strURI;
cLog(lsINFO) << "SMS: Request: '" << strText << "'";

View File

@@ -187,6 +187,38 @@ std::string strCopy(const std::vector<unsigned char>& vucSrc)
}
extern std::string urlEncode(const std::string& strSrc)
{
std::string strDst;
int iOutput = 0;
int iSize = strSrc.length();
strDst.resize(iSize*3);
for (int iInput = 0; iInput < iSize; iInput++) {
unsigned char c = strSrc[iInput];
if (c == ' ')
{
strDst[iOutput++] = '+';
}
else if (isalnum(c))
{
strDst[iOutput++] = c;
}
else
{
strDst[iOutput++] = '%';
strDst[iOutput++] = charHex(c >> 4);
strDst[iOutput++] = charHex(c & 15);
}
}
strDst.resize(iOutput);
return strDst;
}
//
// DH support
//

View File

@@ -103,6 +103,8 @@ int iToSeconds(boost::posix_time::ptime ptWhen);
boost::posix_time::ptime ptFromSeconds(int iSeconds);
uint64_t utFromSeconds(int iSeconds);
extern std::string urlEncode(const std::string& strSrc);
/*
void intIPtoStr(int ip,std::string& retStr);
int strIPtoInt(std::string& ipStr);