aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSona Kurazyan <sona.kurazyan@qt.io>2019-04-15 15:58:57 +0200
committerSona Kurazyan <sona.kurazyan@qt.io>2019-04-17 07:30:51 +0000
commita9a0561e52fd6fb4352d3fc178ee549df9add576 (patch)
tree65ce63f1e3820cf5ce7d6c46b08d030b5209b714
parent435bee7c8fa570afe11ec0957d6ba26f5d28e172 (diff)
Fix URL adjustment of URLs with no host
QUrl can have an empty host, but still considered to be valid. This is possible, for example, when setting an invalid host address or when the URL is a path. Adjusting such URLs leads to unexpected results. Added a check for preventing sending requests to URLs with no host. Fixes: QTBUG-75155 Change-Id: I6c899f824233f32cddb8c9255fd3d1c333bb6385 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r--src/coap/qcoaprequest.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/coap/qcoaprequest.cpp b/src/coap/qcoaprequest.cpp
index 64e0963..58420ac 100644
--- a/src/coap/qcoaprequest.cpp
+++ b/src/coap/qcoaprequest.cpp
@@ -315,6 +315,11 @@ QUrl QCoapRequest::adjustedUrl(const QUrl &url, bool secure)
finalizedUrl.setScheme(scheme);
}
+ if (finalizedUrl.host().isEmpty()) {
+ qCWarning(lcCoapExchange) << "The requested URL" << url << "is not a valid CoAP URL.";
+ return QUrl();
+ }
+
if (url.port() == -1) {
const auto port = secure ? QtCoap::DefaultSecurePort : QtCoap::DefaultPort;
finalizedUrl.setPort(port);