cool#9219 clipboard: only download clipboard-looking URLs

The net.service_root setting means we can't require that this is at the
start, but at least we should not accept any random URLs there.

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I2f492564066206d17d66d966e77e6abaf8104d1a
This commit is contained in:
Miklos Vajna 2024-06-07 16:03:19 +02:00 committed by Caolán McNamara
parent fa1a4771b1
commit 010bab3b77

View file

@ -350,10 +350,18 @@ void ClientSession::handleClipboardRequest(DocumentBroker::ClipboardRequest
std::shared_ptr<http::Session> httpSession = http::Session::create(url);
httpSession->setFinishedHandler(std::move(finishedCallback));
http::Request httpRequest(Poco::URI(url).getPathAndQuery());
if (!httpSession->asyncRequest(httpRequest, docBroker->getPoll()))
std::string pathAndQuery = Poco::URI(url).getPathAndQuery();
if (pathAndQuery.find("/cool/clipboard") != std::string::npos)
{
LOG_ERR("Failed to start an async clipboard download request");
http::Request httpRequest(Poco::URI(url).getPathAndQuery());
if (!httpSession->asyncRequest(httpRequest, docBroker->getPoll()))
{
LOG_ERR("Failed to start an async clipboard download request");
}
}
else
{
LOG_ERR("Clipboard download URL does not look like a clipboard one");
}
}
}