diff --git a/src/webui/api/torrentcreatorcontroller.cpp b/src/webui/api/torrentcreatorcontroller.cpp index 8167ec99f..e3f3769e7 100644 --- a/src/webui/api/torrentcreatorcontroller.cpp +++ b/src/webui/api/torrentcreatorcontroller.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include "base/global.h" #include "base/bittorrent/torrentcreationmanager.h" @@ -88,6 +89,17 @@ namespace } #endif + QStringList parseUrls(const QString &urlsParam) + { + // Empty lines are preserved because they indicate new tracker tier and will be ignored in url seeds. + const QStringList encodedUrls = urlsParam.split(u'|'); + QStringList urls; + urls.reserve(encodedUrls.size()); + for (const QString &urlStr : encodedUrls) + urls << QUrl::fromPercentEncoding(urlStr.toLatin1()); + return urls; + } + QString taskStatusString(const std::shared_ptr task) { if (task->isFailed()) @@ -130,8 +142,8 @@ void TorrentCreatorController::addTaskAction() .torrentFilePath = Path(params()[KEY_TORRENT_FILE_PATH]), .comment = params()[KEY_COMMENT], .source = params()[KEY_SOURCE], - .trackers = params()[KEY_TRACKERS].split(u'|'), - .urlSeeds = params()[KEY_URL_SEEDS].split(u'|') + .trackers = parseUrls(params()[KEY_TRACKERS]), + .urlSeeds = parseUrls(params()[KEY_URL_SEEDS]) }; bool const startSeeding = parseBool(params()[u"startSeeding"_s]).value_or(createTorrentParams.torrentFilePath.isEmpty());