From f5ff969cd497355dcf2e3b58d98ab053fea7cb39 Mon Sep 17 00:00:00 2001 From: James Turner Date: Tue, 8 May 2018 06:50:15 +0100 Subject: [PATCH] Warning improvements when requesting bad URLs Found while debugging some issues with add-default-catalog flow in the launcher. --- simgear/io/HTTPClient.cxx | 7 ++++++- simgear/package/Root.cxx | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/simgear/io/HTTPClient.cxx b/simgear/io/HTTPClient.cxx index eab0258c..fe6fa737 100644 --- a/simgear/io/HTTPClient.cxx +++ b/simgear/io/HTTPClient.cxx @@ -242,8 +242,13 @@ void Client::makeRequest(const Request_ptr& r) if( r->isComplete() ) return; + if (r->url().empty()) { + r->setFailure(EINVAL, "no URL specified on request"); + return; + } + if( r->url().find("://") == std::string::npos ) { - r->setFailure(EINVAL, "malformed URL"); + r->setFailure(EINVAL, "malformed URL: '" + r->url() + "'"); return; } diff --git a/simgear/package/Root.cxx b/simgear/package/Root.cxx index 226e632e..d7e06b4f 100644 --- a/simgear/package/Root.cxx +++ b/simgear/package/Root.cxx @@ -778,6 +778,11 @@ bool Root::removeCatalogById(const std::string& aId) void Root::requestThumbnailData(const std::string& aUrl) { + if (aUrl.empty()) { + SG_LOG(SG_GENERAL, SG_DEV_WARN, "requestThumbnailData: empty URL requested"); + return; + } + auto it = d->thumbnailCache.find(aUrl); if (it == d->thumbnailCache.end()) { bool cachedOnDisk = d->checkPersistentCache(aUrl);