Merge #12723: Qt5: Warning users about invalid-BIP21 URI bitcoin://

b7fbcc5 Qt: Warn users about invalid-BIP21 URI bitcoin:// (Alexey Ivanov)

Pull request description:

  This change affects only Qt5 users, since Qt4 QUrl don't forces lower case for urls. Also bitcoin-qt builds against Qt4 on linux.

  PR for #11645

Tree-SHA512: 6b8cb18b29dbd2754e190a662ed67274a7f0decc6adb00b7e1af107d5f8ea2845b668cf28d6ccf2f1d15e8ef212f5a76910810634a4c15e7fabd1dd2072e7232
This commit is contained in:
Wladimir J. van der Laan 2018-03-21 16:57:10 +01:00 committed by pasta
parent 4f77eff89c
commit 898423ccad
No known key found for this signature in database
GPG Key ID: 52527BEDABE87984
3 changed files with 7 additions and 10 deletions

View File

@ -423,14 +423,6 @@ bool parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out)
bool parseBitcoinURI(QString uri, SendCoinsRecipient *out)
{
// Convert dash:// to dash:
//
// Cannot handle this later, because dash:// will cause Qt to see the part after // as host,
// which will lower-case it (and thus invalidate the address).
if(uri.startsWith("dash://", Qt::CaseInsensitive))
{
uri.replace(0, 7, "dash:");
}
QUrl uriInstance(uri);
return parseBitcoinURI(uriInstance, out);
}

View File

@ -396,7 +396,12 @@ void PaymentServer::handleURIOrFile(const QString& s)
return;
}
if (s.startsWith(BITCOIN_IPC_PREFIX, Qt::CaseInsensitive)) // dash: URI
if (s.startsWith("dash://", Qt::CaseInsensitive))
{
Q_EMIT message(tr("URI handling"), tr("'dash://' is not a valid URI. Use 'dash:' instead."),
CClientUIInterface::MSG_ERROR);
}
else if (s.startsWith(BITCOIN_IPC_PREFIX, Qt::CaseInsensitive)) // dash: URI
{
QUrlQuery uri((QUrl(s)));
if (uri.hasQueryItem("r")) // payment request URI

View File

@ -51,7 +51,7 @@ void URITests::uriTests()
QVERIFY(rv.address == QString("XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg"));
QVERIFY(rv.label == QString());
QVERIFY(GUIUtil::parseBitcoinURI("dash://XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg?message=Some Example Address", &rv));
QVERIFY(GUIUtil::parseBitcoinURI("dash:XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg?message=Some Example Address", &rv));
QVERIFY(rv.address == QString("XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg"));
QVERIFY(rv.label == QString());