fixed web access if rpcpath is empty

This commit is contained in:
orignal
2026-10-15 16:19:42 -04:00
parent 0a9e872fca
commit 24ab7d1237
+21 -9
View File
@@ -968,24 +968,36 @@ namespace torrents
auto subUrlPath = urlPath.begin ();
if (subUrlPath != urlPath.end () && *subUrlPath == "/")
{
std::string tunnelPath ("/");
subUrlPath++;
if (subUrlPath != urlPath.end ())
{
std::string tunnelPath { "/" + subUrlPath->string () + "/rpc" };
if (*subUrlPath != "web")
{
tunnelPath += subUrlPath->string () + "/rpc";
subUrlPath++;
if (subUrlPath != urlPath.end ())
isPathValid = *subUrlPath == "web";
}
else
{
isPathValid = true;
tunnelPath += "rpc";
}
}
if (isPathValid)
{
auto tunnel = m_Server.GetTunnel (tunnelPath);
if (tunnel && tunnel->SupportsWeb ())
{
subUrlPath++;
if (subUrlPath != urlPath.end ())
isPathValid = *subUrlPath == "web";
if (isPathValid)
{
subUrlPath++;
fileSubUrl = std::accumulate (subUrlPath, urlPath.end (), std::filesystem::path{}, std::divides{});
}
fileSubUrl = std::accumulate (subUrlPath, urlPath.end (), std::filesystem::path{}, std::divides{});
}
else
LogPrint (eLogDebug, "TorrentsRPC: Tunnel not found or web is not supported ", subUrlPath->string ());
{
LogPrint (eLogDebug, "TorrentsRPC: Tunnel not found or web is not supported ", tunnelPath);
isPathValid = false;
}
}
}
if (!isPathValid || fileSubUrl.string ().find ("..") != std::string::npos || fileSubUrl == ".")