diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2015-04-13 19:10:20 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2015-04-13 19:10:20 +0000 |
commit | 1fba29f58dee5744dd0266b7368b5c004679c011 (patch) | |
tree | 1cf635e833040b3baadf7d96cc73127e475e9c95 /protocols/SkypeWeb/src | |
parent | fcea54dc0f606c10807fd6b8344e43b547f10d53 (diff) |
SkypeWeb: escaping json on sending
git-svn-id: http://svn.miranda-ng.org/main/trunk@12794 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/SkypeWeb/src')
-rw-r--r-- | protocols/SkypeWeb/src/main.cpp | 2 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/requests/messages.h | 49 |
2 files changed, 37 insertions, 14 deletions
diff --git a/protocols/SkypeWeb/src/main.cpp b/protocols/SkypeWeb/src/main.cpp index d4ba2fdf65..3c95a3cf8f 100644 --- a/protocols/SkypeWeb/src/main.cpp +++ b/protocols/SkypeWeb/src/main.cpp @@ -48,7 +48,7 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) return &pluginInfo;
}
-extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_PROTOCOL, MIID_LAST};
+extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOCOL, MIID_LAST };
extern "C" int __declspec(dllexport) Load(void)
{
diff --git a/protocols/SkypeWeb/src/requests/messages.h b/protocols/SkypeWeb/src/requests/messages.h index 663a075a7b..1eb0115ae3 100644 --- a/protocols/SkypeWeb/src/requests/messages.h +++ b/protocols/SkypeWeb/src/requests/messages.h @@ -27,12 +27,18 @@ public: Headers
<< CHAR_VALUE("Accept", "application/json, text/javascript")
<< FORMAT_VALUE("RegistrationToken", "registrationToken=%s", regToken)
- << CHAR_VALUE("Content-Type", "application/json; charset = UTF-8");
+ << CHAR_VALUE("Content-Type", "application/json; charset=UTF-8");
- CMStringA data;
- data.AppendFormat("{\"clientmessageid\":\"%lld\",\"content\":\"%s\",\"messagetype\":\"RichText\",\"contenttype\":\"text\"}", timestamp, message);
+ JSONNODE *node = json_new(5);
+ json_push_back(node, json_new_i("clientmessageid", timestamp));
+ json_push_back(node, json_new_a("messagetype", "RichText"));
+ json_push_back(node, json_new_a("contenttype", "text"));
+ json_push_back(node, json_new_a("content", message));
+ ptrA data(mir_utf8encodeT(ptrT(json_write(node))));
Body << VALUE(data);
+
+ json_delete(node);
}
};
@@ -45,12 +51,22 @@ public: Headers
<< CHAR_VALUE("Accept", "application/json, text/javascript")
<< FORMAT_VALUE("RegistrationToken", "registrationToken=%s", regToken)
- << CHAR_VALUE("Content-Type", "application/json; charset = UTF-8");
+ << CHAR_VALUE("Content-Type", "application/json; charset=UTF-8");
+
+ CMStringA content;
+ content.AppendFormat("%s %s", username, message);
- CMStringA data;
- data.AppendFormat("{\"clientmessageid\":\"%lld\",\"content\":\"%s %s\",\"messagetype\":\"RichText\",\"contenttype\":\"text\",\"skypeemoteoffset\":\"%d\"}", timestamp, username, message, (int)(mir_strlen(username) + 1));
+ JSONNODE *node = json_new(5);
+ json_push_back(node, json_new_i("clientmessageid", timestamp));
+ json_push_back(node, json_new_a("messagetype", "RichText"));
+ json_push_back(node, json_new_a("contenttype", "text"));
+ json_push_back(node, json_new_a("content", content));
+ json_push_back(node, json_new_i("skypeemoteoffset", (int)(mir_strlen(username) + 1)));
+ ptrA data(mir_utf8encodeT(ptrT(json_write(node))));
Body << VALUE(data);
+
+ json_delete(node);
}
};
@@ -63,13 +79,20 @@ public: Headers
<< CHAR_VALUE("Accept", "application/json, text/javascript")
<< FORMAT_VALUE("RegistrationToken", "registrationToken=%s", regToken)
- << CHAR_VALUE("Content-Type", "application/json; charset = UTF-8");
- CMStringA state;
- state = (iState == PROTOTYPE_SELFTYPING_ON) ? "Control/Typing" : "Control/ClearTyping";
- CMStringA data;
- data.AppendFormat("{\"clienmessageid\":%lld, \"content\":\"\", \"messagetype\":\"%s\", \"contenttype\":\"text\"}", time(NULL), state);
+ << CHAR_VALUE("Content-Type", "application/json; charset=UTF-8");
+ char *state = (iState == PROTOTYPE_SELFTYPING_ON) ? "Control/Typing" : "Control/ClearTyping";
+
+ JSONNODE *node = json_new(5);
+ json_push_back(node, json_new_i("clientmessageid", time(NULL)));
+ json_push_back(node, json_new_a("messagetype", state));
+ json_push_back(node, json_new_a("contenttype", "text"));
+ json_push_back(node, json_new_a("content", ""));
+
+ ptrA data(mir_utf8encodeT(ptrT(json_write(node))));
Body << VALUE(data);
+
+ json_delete(node);
}
};
@@ -82,7 +105,7 @@ public: Headers
<< CHAR_VALUE("Accept", "application/json, text/javascript")
<< FORMAT_VALUE("RegistrationToken", "registrationToken=%s", regToken)
- << CHAR_VALUE("Content-Type", "application/json; charset = UTF-8");
+ << CHAR_VALUE("Content-Type", "application/json; charset=UTF-8");
}
};
@@ -95,7 +118,7 @@ public: Headers
<< CHAR_VALUE("Accept", "application/json, text/javascript")
<< FORMAT_VALUE("RegistrationToken", "registrationToken=%s", regToken)
- << CHAR_VALUE("Content-Type", "application/json; charset = UTF-8");
+ << CHAR_VALUE("Content-Type", "application/json; charset=UTF-8");
}
};
|