1 Description: mqtt plugin: Fix invalid symbols in topic name.
2 Author: Denys Fedoryshchenko <denys@visp.net.lb>
4 diff --git a/src/mqtt.c b/src/mqtt.c
5 index 6b76af97b..8a24ccaa0 100644
6 --- a/src/mqtt.c
7 +++ b/src/mqtt.c
8 @@ -462,6 +462,7 @@ static int format_topic(char *buf, size_t buf_len, data_set_t const *ds,
9 value_list_t const *vl, mqtt_client_conf_t *conf) {
10 char name[MQTT_MAX_TOPIC_SIZE];
11 int status;
12 + char *c;
14 if ((conf->topic_prefix == NULL) || (conf->topic_prefix[0] == 0))
15 return (FORMAT_VL(buf, buf_len, vl));
16 @@ -474,6 +475,10 @@ static int format_topic(char *buf, size_t buf_len, data_set_t const *ds,
17 if ((status < 0) || (((size_t)status) >= buf_len))
18 return (ENOMEM);
20 + while((c = strchr(buf, '#')) || (c = strchr(buf, '+'))) {
21 + *c = '_';
22 + }
23 +
24 return (0);
25 } /* int format_topic */