From aa8f420681aa45c2f0dee9119c01809cd2d0b18e Mon Sep 17 00:00:00 2001 From: thalieht Date: Tue, 20 Jul 2021 14:30:37 +0300 Subject: [PATCH] Recognise v2 info-hashes in clipboard for "Add torrent link" dialog (#15206) --- src/gui/downloadfromurldialog.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gui/downloadfromurldialog.cpp b/src/gui/downloadfromurldialog.cpp index 1d85a385d..e65c7664f 100644 --- a/src/gui/downloadfromurldialog.cpp +++ b/src/gui/downloadfromurldialog.cpp @@ -49,8 +49,12 @@ namespace || str.startsWith("https://", Qt::CaseInsensitive) || str.startsWith("ftp://", Qt::CaseInsensitive) || str.startsWith("magnet:", Qt::CaseInsensitive) - || ((str.size() == 40) && !str.contains(QRegularExpression("[^0-9A-Fa-f]"))) - || ((str.size() == 32) && !str.contains(QRegularExpression("[^2-7A-Za-z]")))); + || ((str.size() == 40) && !str.contains(QRegularExpression("[^0-9A-Fa-f]"))) // v1 hex-encoded SHA-1 info-hash +#if (LIBTORRENT_VERSION_NUM >= 20000) + || ((str.size() == 64) && !str.contains(QRegularExpression("[^0-9A-Fa-f]"))) // v2 hex-encoded SHA-256 info-hash +#endif + || ((str.size() == 32) && !str.contains(QRegularExpression("[^2-7A-Za-z]")))); // v1 Base32 encoded SHA-1 info-hash + } }