Validate Pastebin URL with regex

This commit is contained in:
Lenny McLennington 2022-01-26 00:31:08 +00:00
parent af20b5ee0e
commit 0eff21a4f1
No known key found for this signature in database
GPG Key ID: F0467078ECA45FCB
2 changed files with 19 additions and 2 deletions

View File

@ -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();
}

View File

@ -38,7 +38,7 @@
<property name="title">
<string>Pastebin URL</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_10">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="Line" name="line">
<property name="orientation">
@ -46,6 +46,21 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Note: only input that starts with &lt;span style=&quot; font-weight:600;&quot;&gt;http://&lt;/span&gt; or &lt;span style=&quot; font-weight:600;&quot;&gt;https://&lt;/span&gt; will be accepted.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="urlChoices">
<property name="editable">
@ -69,7 +84,7 @@
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;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.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;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.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>