]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
mqtt: extend the error message for no topic
authorDaniel Stenberg <daniel@haxx.se>
Wed, 30 Jun 2021 06:30:24 +0000 (08:30 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 30 Jun 2021 13:02:24 +0000 (15:02 +0200)
... and mention that it needs URL encoding.

Reported-by: Peter Körner
Fixes #7316
Closes #7317

lib/mqtt.c

index 9a3ca222f14e901fa30355c63d2ffa6aa2c6c595..81bf37864ef60ad1997a3f1c86236d98b2508622 100644 (file)
@@ -378,22 +378,14 @@ fail:
 static CURLcode mqtt_get_topic(struct Curl_easy *data,
                                char **topic, size_t *topiclen)
 {
-  CURLcode result = CURLE_OK;
   char *path = data->state.up.path;
-
-  if(strlen(path) > 1) {
-    result = Curl_urldecode(data, path + 1, 0, topic, topiclen,
-                            REJECT_NADA);
-  }
-  else {
-    failf(data, "Error: No topic specified.");
-    result = CURLE_URL_MALFORMAT;
-  }
-  return result;
+  if(strlen(path) > 1)
+    return Curl_urldecode(data, path + 1, 0, topic, topiclen,
+                          REJECT_NADA);
+  failf(data, "No MQTT topic found. Forgot to URL encode it?");
+  return CURLE_URL_MALFORMAT;
 }
 
-
-
 static CURLcode mqtt_subscribe(struct Curl_easy *data)
 {
   CURLcode result = CURLE_OK;