Skip to content

Commit dc11219

Browse files
committed
Future: Introduce future function to validate proposal strings
Future implementation of string validation on the network level for proposal name/URL
1 parent 54c0d10 commit dc11219

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/budget/budgetproposal.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "budget/budgetproposal.h"
77
#include "chainparams.h"
88
#include "script/standard.h"
9+
#include "utilstrencodings.h"
910

1011
CBudgetProposal::CBudgetProposal():
1112
nAllotted(0),
@@ -145,6 +146,20 @@ bool CBudgetProposal::CheckAddress()
145146
return true;
146147
}
147148

149+
/* TODO: Add this to IsWellFormed() for the next hard-fork
150+
* This will networkly reject malformed proposal names and URLs
151+
*/
152+
bool CBudgetProposal::CheckStrings()
153+
{
154+
if (strProposalName != SanitizeString(strProposalName)) {
155+
strInvalid = "Proposal name contains illegal characters.";
156+
return false;
157+
}
158+
if (strURL != SanitizeString(strURL)) {
159+
strInvalid = "Proposal URL contains illegal characters.";
160+
}
161+
}
162+
148163
bool CBudgetProposal::IsWellFormed(const CAmount& nTotalBudget)
149164
{
150165
return CheckStartEnd() && CheckAmount(nTotalBudget) && CheckAddress();

src/budget/budgetproposal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class CBudgetProposal
4242
bool CheckStartEnd();
4343
bool CheckAmount(const CAmount& nTotalBudget);
4444
bool CheckAddress();
45+
bool CheckStrings();
4546

4647
protected:
4748
std::map<COutPoint, CBudgetVote> mapVotes;

0 commit comments

Comments
 (0)