]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
push-notification plugin: properly terminate strings
authorMichael Koch <michael.koch@open-xchange.com>
Wed, 16 Aug 2017 10:53:55 +0000 (13:53 +0300)
committerJosef 'Jeff' Sipek <jeff.sipek@dovecot.fi>
Wed, 16 Aug 2017 10:53:55 +0000 (13:53 +0300)
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).

src/plugins/push-notification/push-notification-driver-ox.c

index 96624d489915e1309cc683af2c87465b8b2a54d7..49abf4d23a84f0c8a7d9b4ca16818cc637bb818e 100644 (file)
@@ -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, "}");