changeset 22462:84f660d41c24

push-notification plugin: properly terminate strings 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).
author Michael Koch <michael.koch@open-xchange.com>
date Wed, 16 Aug 2017 13:53:55 +0300
parents 618910705ddd
children eb2db4c6e574
files src/plugins/push-notification/push-notification-driver-ox.c
diffstat 1 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/push-notification/push-notification-driver-ox.c	Tue Jul 25 09:35:31 2017 +0300
+++ b/src/plugins/push-notification/push-notification-driver-ox.c	Wed Aug 16 13:53:55 2017 +0300
@@ -389,19 +389,20 @@
     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, "}");