mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-02 09:55:55 +00:00
parent
5173a56ebd
commit
ab0c82965c
@ -635,22 +635,13 @@ Path Session::downloadPath() const
|
|||||||
|
|
||||||
bool Session::isValidCategoryName(const QString &name)
|
bool Session::isValidCategoryName(const QString &name)
|
||||||
{
|
{
|
||||||
const QRegularExpression re(uR"(^([^\\\/]|[^\\\/]([^\\\/]|\/(?=[^\/]))*[^\\\/])$)"_qs);
|
const QRegularExpression re {uR"(^([^\\\/]|[^\\\/]([^\\\/]|\/(?=[^\/]))*[^\\\/])$)"_qs};
|
||||||
if (!name.isEmpty() && (name.indexOf(re) != 0))
|
return (name.isEmpty() || (name.indexOf(re) == 0));
|
||||||
{
|
|
||||||
qDebug() << "Incorrect category name:" << name;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList Session::expandCategory(const QString &category)
|
QStringList Session::expandCategory(const QString &category)
|
||||||
{
|
{
|
||||||
QStringList result;
|
QStringList result;
|
||||||
if (!isValidCategoryName(category))
|
|
||||||
return result;
|
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
while ((index = category.indexOf(u'/', index)) >= 0)
|
while ((index = category.indexOf(u'/', index)) >= 0)
|
||||||
{
|
{
|
||||||
|
@ -717,15 +717,13 @@ QString TorrentImpl::category() const
|
|||||||
|
|
||||||
bool TorrentImpl::belongsToCategory(const QString &category) const
|
bool TorrentImpl::belongsToCategory(const QString &category) const
|
||||||
{
|
{
|
||||||
if (m_category.isEmpty()) return category.isEmpty();
|
if (m_category.isEmpty())
|
||||||
if (!Session::isValidCategoryName(category)) return false;
|
return category.isEmpty();
|
||||||
|
|
||||||
if (m_category == category) return true;
|
if (m_category == category)
|
||||||
|
|
||||||
if (m_session->isSubcategoriesEnabled() && m_category.startsWith(category + u'/'))
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return (m_session->isSubcategoriesEnabled() && m_category.startsWith(category + u'/'));
|
||||||
}
|
}
|
||||||
|
|
||||||
TagSet TorrentImpl::tags() const
|
TagSet TorrentImpl::tags() const
|
||||||
|
Loading…
x
Reference in New Issue
Block a user