-
-
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
Add WebAPI for managing torrent WebSeeds #21043
Conversation
src/webui/api/torrentscontroller.cpp
Outdated
// sanity check before parsing to prevent QUrl from checking for the existence of files on the filesystem | ||
if (!supportedWebseedSchemes.contains(urlStr.section(u"://"_s, 0, 0))) | ||
return nonstd::make_unexpected(TorrentsController::tr("URL scheme must be one of [%1]").arg(supportedWebseedSchemes.join(u","))); | ||
|
||
const QUrl url(urlStr, QUrl::StrictMode); | ||
if (!url.isValid()) | ||
return nonstd::make_unexpected(TorrentsController::tr("\"%1\" is not a valid url").arg(urlStr)); | ||
|
||
// sanity check after parsing in case QUrl interpereted a different scheme than intended | ||
if (!supportedWebseedSchemes.contains(url.scheme())) | ||
return nonstd::make_unexpected(TorrentsController::tr("URL scheme must be one of [%1]").arg(supportedWebseedSchemes.join(u","))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QUrl has support for reading local files, without (unfortunately) any explicit way to disable it. It appears that the only way to prevent QUrl from searching for files on the local filesystem is to ensure that a scheme is explicitly provided. I've taken the approach of supporting http
, https
, and ftp
. This appears to align with BEP 19 and BEP 17, but wanted to call it out in case there are any other opinions. We can of course always modify this later if we run into issues.
3e3b253
to
1a2de33
Compare
I pushed up a change to handle url encoded URLs. URLs sent to this API must be url-encoded to allow for the safe usage of the |
26960a1
to
da2d59b
Compare
@qbittorrent/web-developers this PR is no longer dependent on the custom status code commits from #21015 and is ready for review. |
d9e112d
to
fe9b52e
Compare
8c3c0ba
to
3a7153f
Compare
3a7153f
to
a69085d
Compare
a69085d
to
a3d22b3
Compare
@Piccirello |
Closes #18465.