-
-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WebUI: Unable to remove trackers with |
in their urls
#19074
Comments
Any possibility this can make it in to the next release ? |
Here's a potential patch if we wanted to move forward with this: diff --git a/src/webui/api/torrentscontroller.cpp b/src/webui/api/torrentscontroller.cpp
index ec94daa26..3596dd952 100644
--- a/src/webui/api/torrentscontroller.cpp
+++ b/src/webui/api/torrentscontroller.cpp
@@ -854,8 +854,20 @@ void TorrentsController::removeTrackersAction()
if (!torrent)
throw APIError(APIErrorType::NotFound);
+ const bool encoded = parseBool(params()[u"encoded"_s]).value_or(false);
const QStringList urls = params()[u"urls"_s].split(u'|');
- torrent->removeTrackers(urls);
+ if (encoded) {
+ QStringList decodedUrls;
+ for (const QString &url : urls)
+ {
+ decodedUrls.append(QUrl::fromPercentEncoding(url.toUtf8()));
+ }
+
+ torrent->removeTrackers(decodedUrls);
+ }
+ else {
+ torrent->removeTrackers(urls);
+ }
if (!torrent->isPaused())
torrent->forceReannounce();
diff --git a/src/webui/www/private/scripts/prop-trackers.js b/src/webui/www/private/scripts/prop-trackers.js
index 015759a99..ca823560f 100644
--- a/src/webui/www/private/scripts/prop-trackers.js
+++ b/src/webui/www/private/scripts/prop-trackers.js
@@ -220,7 +220,8 @@ window.qBittorrent.PropTrackers = (function() {
method: 'post',
data: {
hash: current_hash,
- urls: selectedTrackers.join("|")
+ urls: selectedTrackers.map((t) => encodeURI(t)).join("|"),
+ encoded: true,
},
onSuccess: function() {
updateData(); |
Unlike #20592, where we are talking about an unintentionally inserted
IMO, the problem is not that |
Definitely agree, however changing the value separator would be a breaking change. An approach like the patch above would be backwards compatible, if that's important to us. Otherwise changing the value separator is probably easier. Btw I searched through the Web API docs and the only other endpoint I could find that used |
Upcoming v5.0 contains breaking changes anyway, so I would fix this issue by replacing the separators. |
Could you point me to some more info on this? Assuming we're using proper semantic versioning for the WebAPI, it's still on v2, meaning we can't break anything. But I'm we're not using semver and/or we're ok with breaking changes then I'd like to fix this. |
In qBittorrent WebAPI version x.y.z the numbers have the following meaning:
|
As I stated in #20366 (comment) it is unlikely to be fixed by using another separator character. Doesn't you agree? |
We can enforce the requirement that the individual values are URL encoded. For example, Otherwise, the only other idea I have is to switch to a different content type, like JSON. But that seems like a bigger architectural change that would warrant changing many APIs instead of just the two affected by this. |
I don't think we should enforce such requirements. (How are you going to do that?) |
We enforce it via documentation and by percent decoding values server-side. In some cases a client that's not performing percent encoding of values will not work properly, which is expected given this requirement.
I suspect this would work in the vast majority of cases, but there may be URLs that intentionally use a percent character where it is not part of an encoded character. From Wikipedia:
My fear may be overblown and it's possible your approach would work great in practice (which would be ideal), but I'm just not sure. |
The following is quite satisfactory to "my approach", as it does not actually break the compatibility of existing clients:
|
I don't believe this could apply to the percent character.
|
Good find, I think you are correct. As further evidence, it seems we're already decoding all query parameters without side effects.
This now seems like the best path forward. As I mentioned above, we really only need this on |
qBittorrent & operating system versions
qBittorrent: v4.5.2 x64
Operating system: Arch Linux (6.3.1-zen2-1-zen x86_64)
Qt: 6.4.2
libtorrent-rasterbar: 2.0.8.0
What is the problem?
With Web UI, one cannot possibly remove trackers with
|
in their urls.Steps to reproduce
|
in their url (likehttps://example.com/a?b=c|d|e
) to a seedAdditional context
The controller handling the removal does not seem to provide a way to escape certain characters:
https://github.com/qbittorrent/qBittorrent/blob/b1492bcd7d339ed1e758402d86005ccd4f11610b/src/webui/api/torrentscontroller.cpp#L810C2-L824
Log(s) & preferences file(s)
No response
The text was updated successfully, but these errors were encountered: