Skip to content

Commit

Permalink
push-notification plugin: properly terminate strings
Browse files Browse the repository at this point in the history
Without this fix, if the new message does not contain a from, a subject, and
a snippet the generated JSON will be malformed (the status check at the end
appended a '"' when it shouldn't have).
  • Loading branch information
mkochenough authored and Josef 'Jeff' Sipek committed Aug 16, 2017
1 parent bd18d17 commit 3df6085
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/plugins/push-notification/push-notification-driver-ox.c
Expand Up @@ -372,19 +372,20 @@ static void push_notification_driver_ox_process_msg
if (messagenew->from != NULL) {
str_append(str, ",\"from\":\"");
json_append_escaped(str, messagenew->from);
str_append(str, "\"");
}
if (messagenew->subject != NULL) {
str_append(str, "\",\"subject\":\"");
str_append(str, ",\"subject\":\"");
json_append_escaped(str, messagenew->subject);
str_append(str, "\"");
}
if (messagenew->snippet != NULL) {
str_append(str, "\",\"snippet\":\"");
str_append(str, ",\"snippet\":\"");
json_append_escaped(str, messagenew->snippet);
str_append(str, "\"");
}
if (status_success) {
str_printfa(str, "\",\"unseen\":%u", box_status.unseen);
} else {
str_append(str, "\"");
str_printfa(str, ",\"unseen\":%u", box_status.unseen);
}
str_append(str, "}");

Expand Down

0 comments on commit 3df6085

Please sign in to comment.