mirror of
https://github.com/monero-project/monero-gui.git
synced 2026-12-04 00:38:09 +00:00
windows: reject extra arguments from protocol links
This commit is contained in:
2 files changed
+23
-2
No files matched your search
@@ -374,11 +374,11 @@ Root: HKCU; Subkey: "Software\monero-project\monero-core"; ValueType: string; Va
|
||||
Root: HKCR; Subkey: "monero"; ValueType: "string"; ValueData: "URL:Monero Payment Protocol"; Flags: uninsdeletekey
|
||||
Root: HKCR; Subkey: "monero"; ValueType: "string"; ValueName: "URL Protocol"; ValueData: ""
|
||||
Root: HKCR; Subkey: "monero\DefaultIcon"; ValueType: "string"; ValueData: "{app}\monero-wallet-gui.exe,0"
|
||||
Root: HKCR; Subkey: "monero\shell\open\command"; ValueType: "string"; ValueData: """{app}\monero-wallet-gui.exe"" ""%1"""
|
||||
Root: HKCR; Subkey: "monero\shell\open\command"; ValueType: "string"; ValueData: """{app}\monero-wallet-gui.exe"" -- ""%1"""
|
||||
|
||||
; Configure a custom URI scheme: Links starting with "moneroseed:" will start the GUI wallet exe with the URI as command-line parameter
|
||||
; Used to easily hand over custom seed node info to the wallet, with an URI of the form "moneroseed://a.b.c.d:port"
|
||||
Root: HKCR; Subkey: "moneroseed"; ValueType: "string"; ValueData: "URL:Monero Seed Node Protocol"; Flags: uninsdeletekey
|
||||
Root: HKCR; Subkey: "moneroseed"; ValueType: "string"; ValueName: "URL Protocol"; ValueData: ""
|
||||
Root: HKCR; Subkey: "moneroseed\DefaultIcon"; ValueType: "string"; ValueData: "{app}\monero-wallet-gui.exe,0"
|
||||
Root: HKCR; Subkey: "moneroseed\shell\open\command"; ValueType: "string"; ValueData: """{app}\monero-wallet-gui.exe"" ""%1"""
|
||||
Root: HKCR; Subkey: "moneroseed\shell\open\command"; ValueType: "string"; ValueData: """{app}\monero-wallet-gui.exe"" -- ""%1"""
|
||||
@@ -73,6 +73,10 @@
|
||||
#include "qt/KeysFiles.h"
|
||||
#include "qt/PortableSettings.h"
|
||||
#include "qt/NetworkAccessBlockingFactory.h"
|
||||
#ifdef Q_OS_WIN
|
||||
#include <qt_windows.h>
|
||||
#include <shellapi.h>
|
||||
#endif
|
||||
#ifdef QML_TESTS
|
||||
#include "QmlTestHarness.h"
|
||||
#endif
|
||||
@@ -129,6 +133,23 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
Q_INIT_RESOURCE(translations);
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
// Older installers pass the URI without --.
|
||||
const int uriIndex = argc > 1 && qstrcmp(argv[1], "--") == 0 ? 2 : 1;
|
||||
const QLatin1StringView uri(argc > uriIndex ? argv[uriIndex] : "");
|
||||
if (uri.startsWith(u"monero:", Qt::CaseInsensitive) || uri.startsWith(u"moneroseed:", Qt::CaseInsensitive)) {
|
||||
// Windows substitutes the link into "%1". The CRT and Qt must both see it as one argument.
|
||||
int wideArgc;
|
||||
wchar_t **wideArgv = CommandLineToArgvW(GetCommandLineW(), &wideArgc);
|
||||
const bool singleUri = wideArgv && wideArgc == uriIndex + 1 && argc == wideArgc;
|
||||
LocalFree(wideArgv);
|
||||
if (!singleUri) {
|
||||
qCritical() << "Expected a single argument for a Windows protocol link";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef QML_TESTS
|
||||
int qmlTestResult;
|
||||
if (runQmlTestsIfRequested(argc, argv, qmlTestResult))
|
||||
|
||||
Reference in new issue
Block a user