Skip to content

Commit d43f9d4

Browse files
authored
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
1 parent bcc4b2d commit d43f9d4

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/governance/validators.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ bool CProposalValidator::ValidateName()
9898
return false;
9999
}
100100

101+
if (strName.empty()) {
102+
strErrorMessages += "name cannot be empty;";
103+
return false;
104+
}
105+
101106
static constexpr std::string_view strAllowedChars{"-_abcdefghijklmnopqrstuvwxyz0123456789"};
102107

103108
strName = ToLower(strName);

src/test/data/proposals_invalid.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@
1616
{"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"},
1717
{"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"},
1818
{"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"},
19-
{"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"}
19+
{"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"},
20+
{"end_epoch": 1491368400, "name": "", "payment_address": "XpG61qAVhdyN7AqVZQsHfJL7AEk4dPVinc", "payment_amount": 25.75, "start_epoch": 1474261086, "type": 1, "url": "http://dashcentral.org/dean-miller-5493"}
2021
]

0 commit comments

Comments
 (0)