Skip to content

Commit

Permalink
Fix mosquitto_sub encoding of special characters with %j format.
Browse files Browse the repository at this point in the history
Thanks to Ben Barbour.

Closes #1220.
  • Loading branch information
ralight committed Apr 11, 2019
1 parent 5b7b5ea commit cba3380
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ChangeLog.txt
Expand Up @@ -50,6 +50,8 @@ Client features:
Client fixes:
- mosquitto_pub wouldn't always publish all messages when using `-l` and
QoS>0. This has been fixed.
- mosquitto_sub was incorrectly encoding special characters when using %j
output format. Closes #1220.


1.5.8 - 20190228
Expand Down
2 changes: 1 addition & 1 deletion client/sub_client_output.c
Expand Up @@ -101,7 +101,7 @@ static void write_json_payload(const char *payload, int payloadlen)

for(i=0; i<payloadlen; i++){
if(payload[i] == '"' || payload[i] == '\\' || (payload[i] >=0 && payload[i] < 32)){
printf("\\u%04d", payload[i]);
printf("\\u%04x", payload[i]);
}else{
fputc(payload[i], stdout);
}
Expand Down

0 comments on commit cba3380

Please sign in to comment.