From 0eff21a4f1ee97e4b0a484c608eac9617897446d Mon Sep 17 00:00:00 2001 From: Lenny McLennington Date: Wed, 26 Jan 2022 00:31:08 +0000 Subject: [PATCH] Validate Pastebin URL with regex --- launcher/ui/pages/global/PastePage.cpp | 2 ++ launcher/ui/pages/global/PastePage.ui | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/launcher/ui/pages/global/PastePage.cpp b/launcher/ui/pages/global/PastePage.cpp index 0965da77..7c69e1a4 100644 --- a/launcher/ui/pages/global/PastePage.cpp +++ b/launcher/ui/pages/global/PastePage.cpp @@ -30,7 +30,9 @@ PastePage::PastePage(QWidget *parent) : QWidget(parent), ui(new Ui::PastePage) { + static QRegularExpression validUrlRegExp("https?://.+"); ui->setupUi(this); + ui->urlChoices->setValidator(new QRegularExpressionValidator(validUrlRegExp, ui->urlChoices)); ui->tabWidget->tabBar()->hide();\ loadSettings(); } diff --git a/launcher/ui/pages/global/PastePage.ui b/launcher/ui/pages/global/PastePage.ui index fe372540..2d13a765 100644 --- a/launcher/ui/pages/global/PastePage.ui +++ b/launcher/ui/pages/global/PastePage.ui @@ -38,7 +38,7 @@ Pastebin URL - + @@ -46,6 +46,21 @@ + + + + + 10 + + + + <html><head/><body><p>Note: only input that starts with <span style=" font-weight:600;">http://</span> or <span style=" font-weight:600;">https://</span> will be accepted.</p></body></html> + + + false + + + @@ -69,7 +84,7 @@ - <html><head/><body><p>Here you can choose from a predefined list, or input the URL of a different paste service, provided that it supports the same protocol as 0x0.st, that is POST a file to the URL and return a link in the response body.</p></body></html> + <html><head/><body><p>Here you can choose from a predefined list of paste services, or input the URL of a different paste service of your choice, provided it supports the same protocol as 0x0.st, that is POST a file parameter to the URL and return a link in the response body.</p></body></html> Qt::RichText