diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index f4d404444..25145101a 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -635,22 +635,13 @@ Path Session::downloadPath() const bool Session::isValidCategoryName(const QString &name) { - const QRegularExpression re(uR"(^([^\\\/]|[^\\\/]([^\\\/]|\/(?=[^\/]))*[^\\\/])$)"_qs); - if (!name.isEmpty() && (name.indexOf(re) != 0)) - { - qDebug() << "Incorrect category name:" << name; - return false; - } - - return true; + const QRegularExpression re {uR"(^([^\\\/]|[^\\\/]([^\\\/]|\/(?=[^\/]))*[^\\\/])$)"_qs}; + return (name.isEmpty() || (name.indexOf(re) == 0)); } QStringList Session::expandCategory(const QString &category) { QStringList result; - if (!isValidCategoryName(category)) - return result; - int index = 0; while ((index = category.indexOf(u'/', index)) >= 0) { diff --git a/src/base/bittorrent/torrentimpl.cpp b/src/base/bittorrent/torrentimpl.cpp index 2d6201747..6a2d1dcd4 100644 --- a/src/base/bittorrent/torrentimpl.cpp +++ b/src/base/bittorrent/torrentimpl.cpp @@ -717,15 +717,13 @@ QString TorrentImpl::category() const bool TorrentImpl::belongsToCategory(const QString &category) const { - if (m_category.isEmpty()) return category.isEmpty(); - if (!Session::isValidCategoryName(category)) return false; + if (m_category.isEmpty()) + return category.isEmpty(); - if (m_category == category) return true; - - if (m_session->isSubcategoriesEnabled() && m_category.startsWith(category + u'/')) + if (m_category == category) return true; - return false; + return (m_session->isSubcategoriesEnabled() && m_category.startsWith(category + u'/')); } TagSet TorrentImpl::tags() const