Skip to content
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

Merged
merged 1 commit into from
Aug 11, 2024

Conversation

Piccirello
Copy link
Member

@Piccirello Piccirello commented Jul 9, 2024

Closes #18465.

@Piccirello Piccirello added the WebAPI WebAPI-related issues/changes label Jul 9, 2024
@Piccirello Piccirello requested review from glassez and a team July 9, 2024 21:34
Comment on lines 258 to 270
// 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",")));
Copy link
Member Author

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.

src/webui/api/torrentscontroller.cpp Outdated Show resolved Hide resolved
src/webui/api/torrentscontroller.cpp Outdated Show resolved Hide resolved
src/webui/api/torrentscontroller.cpp Outdated Show resolved Hide resolved
@Piccirello Piccirello force-pushed the api-webseeds branch 2 times, most recently from 3e3b253 to 1a2de33 Compare July 11, 2024 16:53
@Piccirello
Copy link
Member Author

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 | separator. This will prevent the issue from #19074 from further spreading.

@Piccirello
Copy link
Member Author

@qbittorrent/web-developers this PR is no longer dependent on the custom status code commits from #21015 and is ready for review.

src/webui/api/torrentscontroller.cpp Outdated Show resolved Hide resolved
src/webui/api/torrentscontroller.cpp Outdated Show resolved Hide resolved
src/webui/api/torrentscontroller.cpp Outdated Show resolved Hide resolved
src/webui/api/torrentscontroller.cpp Outdated Show resolved Hide resolved
@Piccirello Piccirello force-pushed the api-webseeds branch 2 times, most recently from d9e112d to fe9b52e Compare August 4, 2024 20:58
src/webui/webapplication.h Outdated Show resolved Hide resolved
@Piccirello Piccirello force-pushed the api-webseeds branch 2 times, most recently from 8c3c0ba to 3a7153f Compare August 7, 2024 05:21
@Piccirello Piccirello requested a review from glassez August 7, 2024 05:22
glassez
glassez previously approved these changes Aug 9, 2024
@glassez glassez requested review from a team August 9, 2024 05:14
@glassez glassez changed the title Add WebAPI for managing torrent webseeds Add WebAPI for managing torrent WebSeeds Aug 10, 2024
@Chocobo1 Chocobo1 merged commit ea06eb9 into qbittorrent:master Aug 11, 2024
14 checks passed
@Chocobo1
Copy link
Member

@Piccirello
Thank you!

@glassez glassez modified the milestones: 5.1, 5.0 Aug 15, 2024
brvphoenix pushed a commit to brvphoenix/qBittorrent that referenced this pull request Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WebAPI WebAPI-related issues/changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for updating Web Seeds / HTTP Sources via Web API
3 participants