Refactor: pull alert string sanitization into util

This commit is contained in:
Gavin Andresen
2013-11-02 05:27:42 +10:00
parent 0f90613cbe
commit 17faf56262
3 changed files with 15 additions and 9 deletions

View File

@@ -475,6 +475,19 @@ bool ParseMoney(const char* pszIn, int64_t& nRet)
return true;
}
// safeChars chosen to allow simple messages/URLs/email addresses, but avoid anything
// even possibly remotely dangerous like & or >
static string safeChars("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890 .,;_/:?@");
string SanitizeString(const string& str)
{
string strResult;
for (std::string::size_type i = 0; i < str.size(); i++)
{
if (safeChars.find(str[i]) != std::string::npos)
strResult.push_back(str[i]);
}
return strResult;
}
const signed char p_util_hexdigit[256] =
{ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,