diff options
author | Alexandru Ionut Tripon <alexandru.tripon97@gmail.com> | 2023-08-12 12:42:30 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-12 12:42:30 +0300 |
commit | b3b2e9df35222209b4920202d86091eeeb87f03f (patch) | |
tree | ce44c3877ee36c21279d142b2af1c393e7b87780 /launcher/ui/pages/global/APIPage.cpp | |
parent | ca061080c13042642fb3bd49a29a863756f45866 (diff) | |
parent | 3aba7f8fec45c7c87be486d8f6b5c96f69facf93 (diff) | |
download | PrismLauncher-b3b2e9df35222209b4920202d86091eeeb87f03f.tar.gz PrismLauncher-b3b2e9df35222209b4920202d86091eeeb87f03f.tar.bz2 PrismLauncher-b3b2e9df35222209b4920202d86091eeeb87f03f.zip |
Merge branch 'develop' into feat/acknowledge_release_type
Signed-off-by: Alexandru Ionut Tripon <alexandru.tripon97@gmail.com>
Diffstat (limited to 'launcher/ui/pages/global/APIPage.cpp')
-rw-r--r-- | launcher/ui/pages/global/APIPage.cpp | 49 |
1 files changed, 19 insertions, 30 deletions
diff --git a/launcher/ui/pages/global/APIPage.cpp b/launcher/ui/pages/global/APIPage.cpp index dca1b3a6..82aa76a4 100644 --- a/launcher/ui/pages/global/APIPage.cpp +++ b/launcher/ui/pages/global/APIPage.cpp @@ -39,37 +39,30 @@ #include "APIPage.h" #include "ui_APIPage.h" -#include <QMessageBox> #include <QFileDialog> +#include <QMessageBox> #include <QRegularExpression> #include <QStandardPaths> #include <QTabBar> #include <QValidator> #include <QVariant> -#include "settings/SettingsObject.h" -#include "tools/BaseProfiler.h" #include "Application.h" -#include "net/PasteUpload.h" #include "BuildConfig.h" +#include "net/PasteUpload.h" +#include "settings/SettingsObject.h" +#include "tools/BaseProfiler.h" -APIPage::APIPage(QWidget *parent) : - QWidget(parent), - ui(new Ui::APIPage) +APIPage::APIPage(QWidget* parent) : QWidget(parent), ui(new Ui::APIPage) { // This is here so you can reorder the entries in the combobox without messing stuff up - int comboBoxEntries[] = { - PasteUpload::PasteType::Mclogs, - PasteUpload::PasteType::NullPointer, - PasteUpload::PasteType::PasteGG, - PasteUpload::PasteType::Hastebin - }; + int comboBoxEntries[] = { PasteUpload::PasteType::Mclogs, PasteUpload::PasteType::NullPointer, PasteUpload::PasteType::PasteGG, + PasteUpload::PasteType::Hastebin }; static QRegularExpression validUrlRegExp("https?://.+"); - static QRegularExpression validMSAClientID(QRegularExpression::anchoredPattern( - "[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}")); - static QRegularExpression validFlameKey(QRegularExpression::anchoredPattern( - "\\$2[ayb]\\$.{56}")); + static QRegularExpression validMSAClientID( + QRegularExpression::anchoredPattern("[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}")); + static QRegularExpression validFlameKey(QRegularExpression::anchoredPattern("\\$2[ayb]\\$.{56}")); ui->setupUi(this); @@ -77,10 +70,12 @@ APIPage::APIPage(QWidget *parent) : ui->pasteTypeComboBox->addItem(PasteUpload::PasteTypes.at(pasteType).name, pasteType); } - void (QComboBox::*currentIndexChangedSignal)(int) (&QComboBox::currentIndexChanged); + void (QComboBox::*currentIndexChangedSignal)(int)(&QComboBox::currentIndexChanged); connect(ui->pasteTypeComboBox, currentIndexChangedSignal, this, &APIPage::updateBaseURLPlaceholder); // This function needs to be called even when the ComboBox's index is still in its default state. updateBaseURLPlaceholder(ui->pasteTypeComboBox->currentIndex()); + // NOTE: this allows http://, but we replace that with https later anyway + ui->metaURL->setValidator(new QRegularExpressionValidator(validUrlRegExp, ui->metaURL)); ui->baseURLEntry->setValidator(new QRegularExpressionValidator(validUrlRegExp, ui->baseURLEntry)); ui->msaClientID->setValidator(new QRegularExpressionValidator(validMSAClientID, ui->msaClientID)); ui->flameKey->setValidator(new QRegularExpressionValidator(validFlameKey, ui->flameKey)); @@ -108,12 +103,9 @@ void APIPage::resetBaseURLNote() void APIPage::updateBaseURLNote(int index) { - if (baseURLPasteType == index) - { + if (baseURLPasteType == index) { ui->baseURLNote->hide(); - } - else if (!ui->baseURLEntry->text().isEmpty()) - { + } else if (!ui->baseURLEntry->text().isEmpty()) { ui->baseURLNote->show(); } } @@ -134,8 +126,7 @@ void APIPage::loadSettings() ui->baseURLEntry->setText(pastebinURL); int pasteTypeIndex = ui->pasteTypeComboBox->findData(pasteType); - if (pasteTypeIndex == -1) - { + if (pasteTypeIndex == -1) { pasteTypeIndex = ui->pasteTypeComboBox->findData(PasteUpload::PasteType::Mclogs); ui->baseURLEntry->clear(); } @@ -163,17 +154,15 @@ void APIPage::applySettings() QString msaClientID = ui->msaClientID->text(); s->set("MSAClientIDOverride", msaClientID); - QUrl metaURL = ui->metaURL->text(); + QUrl metaURL(ui->metaURL->text()); // Add required trailing slash - if (!metaURL.isEmpty() && !metaURL.path().endsWith('/')) - { + if (!metaURL.isEmpty() && !metaURL.path().endsWith('/')) { QString path = metaURL.path(); path.append('/'); metaURL.setPath(path); } // Don't allow HTTP, since meta is basically RCE with all the jar files. - if(!metaURL.isEmpty() && metaURL.scheme() == "http") - { + if (!metaURL.isEmpty() && metaURL.scheme() == "http") { metaURL.setScheme("https"); } |