Skip to content

Commit def3dc5

Browse files
committed
backout QT changes, merge fuzzball's mods
1 parent 8768556 commit def3dc5

File tree

3 files changed

+20
-24
lines changed

3 files changed

+20
-24
lines changed

src/masternode-budget.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -515,19 +515,6 @@ class CBudgetProposal
515515

516516
void CleanAndRemove(bool fSignatureCheck);
517517

518-
// If URL doesn't have a scheme, add one
519-
std::string GetFixedupURL(std::string scheme="http")
520-
{
521-
std::string ret=strURL;
522-
std::string delim ("://");
523-
if (strURL.find(delim) == std::string::npos)
524-
{
525-
// URL is missing scheme; add one
526-
ret = scheme+"://"+strURL;
527-
}
528-
return ret;
529-
}
530-
531518
uint256 GetHash() const
532519
{
533520
CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);

src/qt/proposalframe.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void ProposalFrame::refresh()
8888

8989
QLabel* strProposalURL = new QLabel();
9090
strProposalURL->setObjectName(QStringLiteral("strProposalURL"));
91-
QString strURL = QString::fromStdString(proposal->GetFixedupURL());
91+
QString strURL = QString::fromStdString(proposal->GetURL());
9292
QString strClick = tr("Open proposal page in browser");
9393
strProposalURL->setText("<a href=\"" + strURL + "\">" + strClick + "</a>");
9494
strProposalURL->setTextFormat(Qt::RichText);
@@ -182,7 +182,7 @@ void ProposalFrame::proposalLink_clicked(const QString &link)
182182
{
183183
QMessageBox Msgbox;
184184
QString strMsgBox = tr("A proposal URL can be used for phishing, scams and computer viruses. Open this link only if you trust the following URL.\n");
185-
strMsgBox += QString::fromStdString(proposal->GetFixedupURL());
185+
strMsgBox += QString::fromStdString(proposal->GetURL());
186186
Msgbox.setText(strMsgBox);
187187
Msgbox.setStandardButtons(QMessageBox::Cancel);
188188
QAbstractButton *openButton = Msgbox.addButton(tr("Open link"), QMessageBox::ApplyRole);
@@ -192,10 +192,10 @@ void ProposalFrame::proposalLink_clicked(const QString &link)
192192
Msgbox.exec();
193193

194194
if (Msgbox.clickedButton() == openButton) {
195-
QDesktopServices::openUrl(QUrl(QString::fromStdString(proposal->GetFixedupURL())));
195+
QDesktopServices::openUrl(QUrl(QString::fromStdString(proposal->GetURL())));
196196
}
197197
if (Msgbox.clickedButton() == copyButton) {
198-
QGuiApplication::clipboard()->setText(QString::fromStdString(proposal->GetFixedupURL()));
198+
QGuiApplication::clipboard()->setText(QString::fromStdString(proposal->GetURL()));
199199
}
200200
governancePage->lockUpdating(false);
201201
}
@@ -246,7 +246,7 @@ void ProposalFrame::voteButton_clicked(int nVote)
246246
questionString += tr("using all your masternodes?");
247247
questionString += "<br /><br />";
248248
questionString += tr("Proposal Hash:") + " " + QString::fromStdString(proposal->GetHash().ToString()) + "<br />";
249-
questionString += tr("Proposal URL:") + " " + QString::fromStdString(proposal->GetFixedupURL());
249+
questionString += tr("Proposal URL:") + " " + QString::fromStdString(proposal->GetURL());
250250
governancePage->lockUpdating(true);
251251
QMessageBox::StandardButton retval = QMessageBox::question(this, tr("Confirm Vote"),
252252
questionString,

src/rpc/budget.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,14 @@ UniValue preparebudget(const UniValue& params, bool fHelp)
8585
std::string strURL = SanitizeString(params[1].get_str());
8686
if (strURL.size() > 64)
8787
throw runtime_error("Invalid url, limit of 64 characters.");
88-
if ((strURL.find("://") == std::string::npos) ||
89-
((strURL.front() != 'h') && (strURL.front() != 'H')))
90-
throw std::runtime_error("Invalid url format, add scheme (e.g. https://).");
9188

89+
if ((strURL.front() == 'h') || (strURL.front() == 'H')) {
90+
std::size_t found = strURL.find("ttp://") == 1 ? strURL.find("ttp://") : strURL.find("ttps://");
91+
if (found != 1)
92+
throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid url, add scheme (e.g. https://)"));
93+
} else {
94+
throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid url, add scheme (e.g. https://)"));
95+
}
9296

9397
int nPaymentCount = params[2].get_int();
9498
if (nPaymentCount < 1)
@@ -184,9 +188,14 @@ UniValue submitbudget(const UniValue& params, bool fHelp)
184188
std::string strURL = SanitizeString(params[1].get_str());
185189
if (strURL.size() > 64)
186190
throw runtime_error("Invalid url, limit of 64 characters.");
187-
if ((strURL.find("://") == std::string::npos) ||
188-
((strURL.front() != 'h') && (strURL.front() != 'H')))
189-
throw std::runtime_error("Invalid url format, add scheme (e.g. https://).");
191+
192+
if ((strURL.front() == 'h') || (strURL.front() == 'H')) {
193+
std::size_t found = strURL.find("ttp://") == 1 ? strURL.find("ttp://") : strURL.find("ttps://");
194+
if (found != 1)
195+
throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid url, add scheme (e.g. https://)"));
196+
} else {
197+
throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid url, add scheme (e.g. https://)"));
198+
}
190199

191200
int nPaymentCount = params[2].get_int();
192201
if (nPaymentCount < 1)

0 commit comments

Comments
 (0)