~shaun-mcbride/pivx-project/trunk

« back to all changes in this revision

Viewing changes to src/utilstrencodings.h

  • Committer: Shaun Mcbride
  • Date: 2019-01-07 02:19:40 UTC
  • Revision ID: shaun.mcbride@gmail.com-20190107021940-almb7zdjfinkuhqt
fresh push for start of new year

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
/** This is needed because the foreach macro can't get over the comma in pair<t1, t2> */
25
25
#define PAIRTYPE(t1, t2) std::pair<t1, t2>
26
26
 
27
 
std::string SanitizeString(const std::string& str);
 
27
/** Used by SanitizeString() */
 
28
enum SafeChars
 
29
{
 
30
    SAFE_CHARS_DEFAULT, //!< The full set of allowed chars
 
31
    SAFE_CHARS_UA_COMMENT, //!< BIP-0014 subset
 
32
    SAFE_CHARS_FILENAME, //!< Chars allowed in filenames
 
33
};
 
34
 
 
35
/**
 
36
* Remove unsafe chars. Safe chars chosen to allow simple messages/URLs/email
 
37
* addresses, but avoid anything even possibly remotely dangerous like & or >
 
38
* @param[in] str    The string to sanitize
 
39
* @param[in] rule   The set of safe chars to choose (default: least restrictive)
 
40
* @return           A new string without unsafe chars
 
41
*/
 
42
std::string SanitizeString(const std::string& str, int rule = SAFE_CHARS_DEFAULT);
28
43
std::vector<unsigned char> ParseHex(const char* psz);
29
44
std::vector<unsigned char> ParseHex(const std::string& str);
30
45
signed char HexDigit(char c);