mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-22 08:27:24 -06:00
WebAPI: Omit file names in parseMetadata response
This allows us to bypass any issues related to non-ascii file names. Supersedes #23080. PR #23085.
This commit is contained in:
committed by
GitHub
parent
bda37cbade
commit
2f34c9b2f0
@@ -2099,16 +2099,14 @@ void TorrentsController::parseMetadataAction()
|
||||
if (uploadedTorrents.isEmpty())
|
||||
throw APIError(APIErrorType::BadParams, tr("Must specify torrent file(s)"));
|
||||
|
||||
QJsonObject result;
|
||||
QJsonArray result;
|
||||
for (auto it = uploadedTorrents.constBegin(); it != uploadedTorrents.constEnd(); ++it)
|
||||
{
|
||||
if (const auto loadResult = BitTorrent::TorrentDescriptor::load(it.value()))
|
||||
{
|
||||
const BitTorrent::TorrentDescriptor &torrentDescr = loadResult.value();
|
||||
m_torrentMetadataCache.insert(torrentDescr.infoHash().toTorrentID(), torrentDescr);
|
||||
|
||||
const QString &fileName = it.key();
|
||||
result.insert(fileName, serializeTorrentInfo(torrentDescr));
|
||||
result.append(serializeTorrentInfo(torrentDescr));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -175,9 +175,11 @@ window.qBittorrent.Client ??= (() => {
|
||||
const uploadTorrentFiles = (files) => {
|
||||
const fileNames = [];
|
||||
const formData = new FormData();
|
||||
for (const file of files) {
|
||||
for (let i = 0; i < files.length; ++i) {
|
||||
const file = files[i];
|
||||
fileNames.push(file.name);
|
||||
formData.append("file", file);
|
||||
// send dummy file name as file name won't be used and may not be encoded properly
|
||||
formData.append("file", file, i);
|
||||
}
|
||||
|
||||
fetch("api/v2/torrents/parseMetadata", {
|
||||
@@ -191,12 +193,9 @@ window.qBittorrent.Client ??= (() => {
|
||||
}
|
||||
|
||||
const json = await response.json();
|
||||
for (const fileName of fileNames) {
|
||||
let title = fileName;
|
||||
const metadata = json[fileName];
|
||||
if (metadata !== undefined)
|
||||
title = metadata.name;
|
||||
|
||||
for (let i = 0; i < json.length; ++i) {
|
||||
const metadata = json[i];
|
||||
const title = metadata.name || fileNames[i];
|
||||
const hash = metadata.infohash_v2 || metadata.infohash_v1;
|
||||
createAddTorrentWindow(title, hash, metadata);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user