Skip to content

Commit e898a66

Browse files
committed
1 parent 73916ee commit e898a66

File tree

1 file changed

+127
-0
lines changed
  • patches/qbittorrent/4.5.1

1 file changed

+127
-0
lines changed

patches/qbittorrent/4.5.1/patch

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
From 3be5273246e9e399041db91892e3dbb281055076 Mon Sep 17 00:00:00 2001
2+
From: Vladimir Golovnev <[email protected]>
3+
Date: Mon, 27 Feb 2023 09:08:18 +0300
4+
Subject: [PATCH 1/3] Prevent RSS folder from being moved into itself
5+
6+
PR #18619.
7+
Closes #18446.
8+
---
9+
src/base/rss/rss_session.cpp | 5 ++++-
10+
src/gui/rss/feedlistwidget.cpp | 10 ++++++----
11+
2 files changed, 10 insertions(+), 5 deletions(-)
12+
13+
diff --git a/src/base/rss/rss_session.cpp b/src/base/rss/rss_session.cpp
14+
index bbc4d413d12..1d1ed81b1dd 100644
15+
--- a/src/base/rss/rss_session.cpp
16+
+++ b/src/base/rss/rss_session.cpp
17+
@@ -185,8 +185,11 @@ nonstd::expected<void, QString> Session::moveItem(Item *item, const QString &des
18+
if (!result)
19+
return result.get_unexpected();
20+
21+
- auto srcFolder = static_cast<Folder *>(m_itemsByPath.value(Item::parentPath(item->path())));
22+
const auto destFolder = result.value();
23+
+ if (static_cast<Item *>(destFolder) == item)
24+
+ return nonstd::make_unexpected(tr("Couldn't move folder into itself."));
25+
+
26+
+ auto srcFolder = static_cast<Folder *>(m_itemsByPath.value(Item::parentPath(item->path())));
27+
if (srcFolder != destFolder)
28+
{
29+
srcFolder->removeItem(item);
30+
diff --git a/src/gui/rss/feedlistwidget.cpp b/src/gui/rss/feedlistwidget.cpp
31+
index 8657dcca82e..428fd95463a 100644
32+
--- a/src/gui/rss/feedlistwidget.cpp
33+
+++ b/src/gui/rss/feedlistwidget.cpp
34+
@@ -105,7 +105,8 @@ FeedListWidget::FeedListWidget(QWidget *parent)
35+
m_rssToTreeItemMapping[RSS::Session::instance()->rootFolder()] = invisibleRootItem();
36+
37+
m_unreadStickyItem = new FeedListItem(this);
38+
- m_unreadStickyItem->setData(0, Qt::UserRole, QVariant::fromValue(RSS::Session::instance()->rootFolder()));
39+
+ m_unreadStickyItem->setData(0, Qt::UserRole, QVariant::fromValue(
40+
+ reinterpret_cast<intptr_t>(RSS::Session::instance()->rootFolder())));
41+
m_unreadStickyItem->setText(0, tr("Unread (%1)").arg(RSS::Session::instance()->rootFolder()->unreadCount()));
42+
m_unreadStickyItem->setData(0, Qt::DecorationRole, UIThemeManager::instance()->getIcon(u"mail-inbox"_qs));
43+
m_unreadStickyItem->setData(0, StickyItemTagRole, true);
44+
@@ -211,9 +212,10 @@ QList<QTreeWidgetItem *> FeedListWidget::getAllOpenedFolders(QTreeWidgetItem *pa
45+
46+
RSS::Item *FeedListWidget::getRSSItem(QTreeWidgetItem *item) const
47+
{
48+
- if (!item) return nullptr;
49+
+ if (!item)
50+
+ return nullptr;
51+
52+
- return item->data(0, Qt::UserRole).value<RSS::Item *>();
53+
+ return reinterpret_cast<RSS::Item *>(item->data(0, Qt::UserRole).value<intptr_t>());
54+
}
55+
56+
QTreeWidgetItem *FeedListWidget::mapRSSItem(RSS::Item *rssItem) const
57+
@@ -275,7 +277,7 @@ QTreeWidgetItem *FeedListWidget::createItem(RSS::Item *rssItem, QTreeWidgetItem
58+
{
59+
auto *item = new FeedListItem;
60+
item->setData(0, Qt::DisplayRole, u"%1 (%2)"_qs.arg(rssItem->name(), QString::number(rssItem->unreadCount())));
61+
- item->setData(0, Qt::UserRole, QVariant::fromValue(rssItem));
62+
+ item->setData(0, Qt::UserRole, QVariant::fromValue(reinterpret_cast<intptr_t>(rssItem)));
63+
m_rssToTreeItemMapping[rssItem] = item;
64+
65+
QIcon icon;
66+
67+
From c21c3d230019431ab8f03faa3471474a66590c9c Mon Sep 17 00:00:00 2001
68+
From: Vladimir Golovnev <[email protected]>
69+
Date: Mon, 27 Feb 2023 09:09:33 +0300
70+
Subject: [PATCH 2/3] WebAPI: Allow to set read-only directory as torrent
71+
location
72+
73+
PR #18613.
74+
Closes #18480.
75+
---
76+
src/webui/api/torrentscontroller.cpp | 4 ----
77+
1 file changed, 4 deletions(-)
78+
79+
diff --git a/src/webui/api/torrentscontroller.cpp b/src/webui/api/torrentscontroller.cpp
80+
index 6ede337e5f0..6080febeae3 100644
81+
--- a/src/webui/api/torrentscontroller.cpp
82+
+++ b/src/webui/api/torrentscontroller.cpp
83+
@@ -1099,10 +1099,6 @@ void TorrentsController::setLocationAction()
84+
if (!Utils::Fs::mkpath(newLocation))
85+
throw APIError(APIErrorType::Conflict, tr("Cannot make save path"));
86+
87+
- // check permissions
88+
- if (!Utils::Fs::isWritable(newLocation))
89+
- throw APIError(APIErrorType::AccessDenied, tr("Cannot write to directory"));
90+
-
91+
applyToTorrents(hashes, [newLocation](BitTorrent::Torrent *const torrent)
92+
{
93+
LogMsg(tr("WebUI Set location: moving \"%1\", from \"%2\" to \"%3\"")
94+
95+
From 38c0864bf2119183e67fb7f2a1d5a8421f82b99f Mon Sep 17 00:00:00 2001
96+
From: Vladimir Golovnev <[email protected]>
97+
Date: Mon, 27 Feb 2023 16:50:50 +0300
98+
Subject: [PATCH 3/3] Reject requests that contain backslash in path
99+
100+
PR #18626.
101+
Closes #18618.
102+
---
103+
src/webui/webapplication.cpp | 11 ++++++++---
104+
1 file changed, 8 insertions(+), 3 deletions(-)
105+
106+
diff --git a/src/webui/webapplication.cpp b/src/webui/webapplication.cpp
107+
index f16e6e81220..629639e8a71 100644
108+
--- a/src/webui/webapplication.cpp
109+
+++ b/src/webui/webapplication.cpp
110+
@@ -151,9 +151,14 @@ WebApplication::~WebApplication()
111+
112+
void WebApplication::sendWebUIFile()
113+
{
114+
- const QStringList pathItems {request().path.split(u'/', Qt::SkipEmptyParts)};
115+
- if (pathItems.contains(u".") || pathItems.contains(u".."))
116+
- throw InternalServerErrorHTTPError();
117+
+ if (request().path.contains(u'\\'))
118+
+ throw BadRequestHTTPError();
119+
+
120+
+ if (const QList<QStringView> pathItems = QStringView(request().path).split(u'/', Qt::SkipEmptyParts)
121+
+ ; pathItems.contains(u".") || pathItems.contains(u".."))
122+
+ {
123+
+ throw BadRequestHTTPError();
124+
+ }
125+
126+
const QString path = (request().path != u"/")
127+
? request().path

0 commit comments

Comments
 (0)