diff options
author | Alexander Gluzsky <sss123next@list.ru> | 2015-12-17 17:21:03 +0000 |
---|---|---|
committer | Alexander Gluzsky <sss123next@list.ru> | 2015-12-17 17:21:03 +0000 |
commit | 3eb593cb61a7a7e2de574a1c54f538f025d90936 (patch) | |
tree | 0619ae16df5c17ddd056527ccd40c0a7e3a82118 /protocols/JabberG/src/jabber_thread.cpp | |
parent | dbb4ff1313ca3a1cd6a80a775da29c18b9f3cda4 (diff) |
protocols:
jabber:
additional sanity check for incomming pgp encrypted message (xep-0027 is not strict enough), this check is required to avoid incompatibility with some clients with xep-0027 support
git-svn-id: http://svn.miranda-ng.org/main/trunk@15885 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/JabberG/src/jabber_thread.cpp')
-rwxr-xr-x[-rw-r--r--] | protocols/JabberG/src/jabber_thread.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index 155bf8f8ad..e723bce2ba 100644..100755 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -1202,11 +1202,27 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData *info) if (ptszText == NULL)
return;
- TCHAR *prolog = _T("-----BEGIN PGP MESSAGE-----\r\n\r\n");
+ //XEP-0027 is not strict enough, different clients have different implementations
+ //additional validation is required
+ TCHAR *prolog = _T("-----BEGIN PGP MESSAGE-----");
+ TCHAR *prolog_newline = _T("\r\n\r\n");
TCHAR *epilog = _T("\r\n-----END PGP MESSAGE-----\r\n");
- size_t len = mir_tstrlen(prolog) + mir_tstrlen(ptszText) + mir_tstrlen(epilog) + 3;
- TCHAR *tempstring = (TCHAR*)_alloca(sizeof(TCHAR)*len);
- mir_sntprintf(tempstring, len, _T("%s%s%s"), prolog, ptszText, epilog);
+
+ size_t len = 0;
+ TCHAR *tempstring = nullptr;
+ if(!_tcsstr(ptszText, prolog))
+ {
+ len = mir_tstrlen(prolog) + mir_tstrlen(prolog_newline) + mir_tstrlen(ptszText) + mir_tstrlen(epilog) + 3;
+ tempstring = (TCHAR*)_alloca(sizeof(TCHAR)*len);
+ mir_sntprintf(tempstring, len, _T("%s%s%s%s"), prolog, prolog_newline, ptszText, epilog);
+ }
+ else
+ {
+ len = mir_tstrlen(ptszText) + 3;
+ tempstring = (TCHAR*)_alloca(sizeof(TCHAR)*len);
+ mir_sntprintf(tempstring, len, _T("%s"), ptszText);
+ }
+
szMessage = tempstring;
}
else if (!mir_tstrcmp(ptszXmlns, JABBER_FEAT_DELAY) && msgTime == 0) {
|