[uacomment] Sanitize per BIP-0014
* SanitizeString() can be requested to be more strict * Throw error when SanitizeString() changes uacomments * Fix tests
This commit is contained in:
@@ -22,8 +22,22 @@
|
||||
/** This is needed because the foreach macro can't get over the comma in pair<t1, t2> */
|
||||
#define PAIRTYPE(t1, t2) std::pair<t1, t2>
|
||||
|
||||
/** Used by SanitizeString() */
|
||||
enum SafeChars
|
||||
{
|
||||
SAFE_CHARS_DEFAULT, //!< The full set of allowed chars
|
||||
SAFE_CHARS_UA_COMMENT //!< BIP-0014 subset
|
||||
};
|
||||
|
||||
std::string SanitizeFilename(const std::string& str);
|
||||
std::string SanitizeString(const std::string& str);
|
||||
/**
|
||||
* Remove unsafe chars. Safe chars chosen to allow simple messages/URLs/email
|
||||
* addresses, but avoid anything even possibly remotely dangerous like & or >
|
||||
* @param[in] str The string to sanitize
|
||||
* @param[in] rule The set of safe chars to choose (default: least restrictive)
|
||||
* @return A new string without unsafe chars
|
||||
*/
|
||||
std::string SanitizeString(const std::string& str, int rule = SAFE_CHARS_DEFAULT);
|
||||
std::string HexInt(uint32_t val);
|
||||
uint32_t ParseHexToUInt32(const std::string& str);
|
||||
std::vector<unsigned char> ParseHex(const char* psz);
|
||||
|
||||
Reference in New Issue
Block a user