fix(gov): do not allow empty proposal names (#4883)

* gov: Do not allow empty proposal names

* Add test for invalid (empty) proposal name

* Use pasta suggestion
This commit is contained in:
Nathan Marley 2022-06-14 06:04:56 -03:00 committed by GitHub
parent bcc4b2d1ac
commit d43f9d4ae1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -98,6 +98,11 @@ bool CProposalValidator::ValidateName()
return false;
}
if (strName.empty()) {
strErrorMessages += "name cannot be empty;";
return false;
}
static constexpr std::string_view strAllowedChars{"-_abcdefghijklmnopqrstuvwxyz0123456789"};
strName = ToLower(strName);

View File

@ -16,5 +16,6 @@
{"end_epoch": 1491368400, "name": "dean-miller-5493", "payment_address": "XpG61qAVhdyN7AqVZQsHfJL7AEk4dPVinc", "payment_amount": "25.75", "start_epoch": 1474261086, "type": 1, "url": "http://dashcentral.org/dean-miller-5493"},
{"end_epoch": "1491368400", "name": "dean-miller-5493", "payment_address": "XpG61qAVhdyN7AqVZQsHfJL7AEk4dPVinc", "payment_amount": 25.75, "start_epoch": 1474261086, "type": 1, "url": "http://dashcentral.org/dean-miller-5493"},
{"end_epoch": 1491368400, "name": "dean-miller-5493", "payment_address": "XpG61qAVhdyN7AqVZQsHfJL7AEk4dPVinc", "payment_amount": 25.75, "start_epoch": "1474261086", "type": 1, "url": "http://dashcentral.org/dean-miller-5493"},
{"end_epoch": 1491368400, "name": "dean-miller-5493", "payment_address": "XpG61qAVhdyN7AqVZQsHfJL7AEk4dPVinc", "payment_amount": 25.75, "start_epoch": 1474261086, "type": 2, "url": "http://dashcentral.org/dean-miller-5493"}
{"end_epoch": 1491368400, "name": "dean-miller-5493", "payment_address": "XpG61qAVhdyN7AqVZQsHfJL7AEk4dPVinc", "payment_amount": 25.75, "start_epoch": 1474261086, "type": 2, "url": "http://dashcentral.org/dean-miller-5493"},
{"end_epoch": 1491368400, "name": "", "payment_address": "XpG61qAVhdyN7AqVZQsHfJL7AEk4dPVinc", "payment_amount": 25.75, "start_epoch": 1474261086, "type": 1, "url": "http://dashcentral.org/dean-miller-5493"}
]