In JSON, output unprintable currency codes as hex

This commit is contained in:
Mark Travis
2014-06-30 23:51:07 +00:00
parent b9f1b05625
commit 9210efb051

View File

@@ -223,6 +223,14 @@ std::string STAmount::createHumanCurrency (const uint160& uCurrency)
{
static uint160 const sIsoBits ("FFFFFFFFFFFFFFFFFFFFFFFF000000FFFFFFFFFF");
// Characters we are willing to include the ASCII representation
// of a three-letter currency code
static std::string legalASCIICurrencyCharacters =
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"0123456789"
"<>(){}[]|?!@#$%^&*";
if (uCurrency.isZero ())
{
return SYSTEM_CURRENCY_CODE;
@@ -244,7 +252,8 @@ std::string STAmount::createHumanCurrency (const uint160& uCurrency)
// Specifying the system currency code using ISO-style representation
// is not allowed.
if (iso != SYSTEM_CURRENCY_CODE)
if ((iso != SYSTEM_CURRENCY_CODE) &&
(iso.find_first_not_of (legalASCIICurrencyCharacters) == std::string::npos))
return iso;
}