Skip to content

Commit

Permalink
mqtt: extend the error message for no topic
Browse files Browse the repository at this point in the history
... and mention that it needs URL encoding.

Reported-by: Peter Körner
Fixes #7316
Closes #7317
  • Loading branch information
bagder committed Jun 30, 2021
1 parent e6caaa4 commit 5372ee3
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions lib/mqtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,22 +378,14 @@ static CURLcode mqtt_verify_connack(struct Curl_easy *data)
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;
Expand Down

0 comments on commit 5372ee3

Please sign in to comment.