mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-24 10:16:00 +03:00
parent
5173a56ebd
commit
ab0c82965c
2 changed files with 6 additions and 17 deletions
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue