Allow uppercase checksums matching in Checksums tab
authorElvis Angelaccio <elvis.angelaccio@kde.org>
Wed, 16 Nov 2016 12:30:01 +0000 (13:30 +0100)
committerMaximiliano Curia <maxy@debian.org>
Wed, 5 Apr 2017 08:10:59 +0000 (09:10 +0100)
While the checksum in cache is always guaranteed to be lowercase, the
one from the line edit may be uppercase. If we make it lowercase
*before* processing it, we can also simplify the regexes.

REVIEW: 129415
BUG: 372518
FIXED-IN: 5.29

Gbp-Pq: Name Allow-uppercase-checksums-matching-in-Checksums-tab.patch

src/widgets/kpropertiesdialog.cpp
src/widgets/kpropertiesdialog_p.h

index d246b056c94cf81de072bb32e0aff54c4af80bcf..8e8861d21e77a94fb5711b1450a9f16a0f605557 100644 (file)
@@ -2662,7 +2662,10 @@ KChecksumsPlugin::KChecksumsPlugin(KPropertiesDialog *dialog)
     d->m_ui.sha1CopyButton->hide();
     d->m_ui.sha256CopyButton->hide();
 
-    connect(d->m_ui.lineEdit, &QLineEdit::textChanged, this, &KChecksumsPlugin::slotVerifyChecksum);
+    connect(d->m_ui.lineEdit, &QLineEdit::textChanged, this, [=](const QString &text) {
+        slotVerifyChecksum(text.toLower());
+    });
+
     connect(d->m_ui.md5Button, &QPushButton::clicked, this, &KChecksumsPlugin::slotShowMd5);
     connect(d->m_ui.sha1Button, &QPushButton::clicked, this, &KChecksumsPlugin::slotShowSha1);
     connect(d->m_ui.sha256Button, &QPushButton::clicked, this, &KChecksumsPlugin::slotShowSha256);
@@ -2813,19 +2816,19 @@ void KChecksumsPlugin::slotVerifyChecksum(const QString &input)
 
 bool KChecksumsPlugin::isMd5(const QString &input)
 {
-    QRegularExpression regex(QStringLiteral("^[a-fA-F0-9]{32}$"));
+    QRegularExpression regex(QStringLiteral("^[a-f0-9]{32}$"));
     return regex.match(input).hasMatch();
 }
 
 bool KChecksumsPlugin::isSha1(const QString &input)
 {
-    QRegularExpression regex(QStringLiteral("^[a-fA-F0-9]{40}$"));
+    QRegularExpression regex(QStringLiteral("^[a-f0-9]{40}$"));
     return regex.match(input).hasMatch();
 }
 
 bool KChecksumsPlugin::isSha256(const QString &input)
 {
-    QRegularExpression regex(QStringLiteral("^[a-fA-F0-9]{64}$"));
+    QRegularExpression regex(QStringLiteral("^[a-f0-9]{64}$"));
     return regex.match(input).hasMatch();
 }
 
index 8ad19e6974ccdeca2b98d4e4c57f8f8830cc0d31..45df38c105ccaba670a1a2b03adcee3eb5269d58 100644 (file)
@@ -176,6 +176,9 @@ private Q_SLOTS:
     void slotShowMd5();
     void slotShowSha1();
     void slotShowSha256();
+    /**
+     * Compare @p input (required to be lowercase) with the checksum in cache.
+     */
     void slotVerifyChecksum(const QString &input);
 
 private: