From 6969c629641e681069d17c117829779191b8896d Mon Sep 17 00:00:00 2001 From: Denys Fedoryshchenko Date: Fri, 6 Jan 2017 03:36:16 +0200 Subject: [PATCH] mqtt plugin: Fix invalid symbols in topic name. --- src/mqtt.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mqtt.c b/src/mqtt.c index 6b76af97..8a24ccaa 100644 --- a/src/mqtt.c +++ b/src/mqtt.c @@ -462,6 +462,7 @@ static int format_topic(char *buf, size_t buf_len, data_set_t const *ds, value_list_t const *vl, mqtt_client_conf_t *conf) { char name[MQTT_MAX_TOPIC_SIZE]; int status; + char *c; if ((conf->topic_prefix == NULL) || (conf->topic_prefix[0] == 0)) return (FORMAT_VL(buf, buf_len, vl)); @@ -474,6 +475,10 @@ static int format_topic(char *buf, size_t buf_len, data_set_t const *ds, if ((status < 0) || (((size_t)status) >= buf_len)) return (ENOMEM); + while((c = strchr(buf, '#')) || (c = strchr(buf, '+'))) { + *c = '_'; + } + return (0); } /* int format_topic */ -- 2.30.2