summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-x[-rw-r--r--]protocols/JabberG/src/jabber_thread.cpp24
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) {