From 2c369e66feacfb3b934b1ec28fcecd179d796ba1 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 24 Jun 2020 11:33:25 +0300 Subject: Jabber: user name to be encoded to avoid spaces --- protocols/JabberG/src/jabber_iqid.cpp | 2 +- protocols/JabberG/src/jabber_menu.cpp | 7 ------- protocols/JabberG/src/jabber_thread.cpp | 2 +- protocols/JabberG/src/jabber_util.cpp | 7 +++++++ protocols/JabberG/src/stdafx.h | 1 + 5 files changed, 10 insertions(+), 9 deletions(-) (limited to 'protocols/JabberG') diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp index 690e936ad8..5f8736b31e 100755 --- a/protocols/JabberG/src/jabber_iqid.cpp +++ b/protocols/JabberG/src/jabber_iqid.cpp @@ -239,7 +239,7 @@ void CJabberProto::OnIqResultGetAuth(const TiXmlElement *iqNode, CJabberIqInfo*) if (!mir_strcmp(type, "result")) { XmlNodeIq iq(AddIQ(&CJabberProto::OnIqResultSetAuth, JABBER_IQ_TYPE_SET)); auto *query = iq << XQUERY("jabber:iq:auth"); - query << XCHILD("username", m_ThreadInfo->conn.username); + query << XCHILD("username", EncodeJid(m_ThreadInfo->conn.username)); if (XmlFirstChild(queryNode, "digest") != nullptr && m_ThreadInfo->szStreamId) { JabberShaStrBuf buf; char text[200]; diff --git a/protocols/JabberG/src/jabber_menu.cpp b/protocols/JabberG/src/jabber_menu.cpp index 92acc5ca6d..ee67312f4a 100644 --- a/protocols/JabberG/src/jabber_menu.cpp +++ b/protocols/JabberG/src/jabber_menu.cpp @@ -799,13 +799,6 @@ int CJabberProto::OnProcessSrmmEvent(WPARAM, LPARAM lParam) if (!hDialogsList) hDialogsList = WindowList_Create(); WindowList_Add(hDialogsList, event->hwndWindow, event->hContact); - - ptrA jid(getUStringA(event->hContact, "jid")); - if (jid != nullptr) { - JABBER_LIST_ITEM *pItem = ListGetItemPtr(LIST_ROSTER, jid); - // if (pItem) - // RetrieveMessageArchive(event->hContact, pItem); - } } else if (event->uType == MSG_WINDOW_EVT_CLOSING) { if (hDialogsList) diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index e911d7f33d..1a631ad89a 100755 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -561,7 +561,7 @@ void CJabberProto::PerformIqAuth(ThreadData *info) { if (!info->bIsReg) { info->send(XmlNodeIq(AddIQ(&CJabberProto::OnIqResultGetAuth, JABBER_IQ_TYPE_GET)) - << XQUERY("jabber:iq:auth") << XCHILD("username", info->conn.username)); + << XQUERY("jabber:iq:auth") << XCHILD("username", EncodeJid(info->conn.username))); } else PerformRegistration(info); } diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp index aa64fb68e7..a23247b435 100755 --- a/protocols/JabberG/src/jabber_util.cpp +++ b/protocols/JabberG/src/jabber_util.cpp @@ -76,6 +76,13 @@ CMStringA MakeJid(const char *jid, const char *resource) return ret; } +CMStringA EncodeJid(const char *jid) +{ + CMStringA ret(jid); + ret.Replace(" ", "\20"); + return ret; +} + void CJabberProto::UpdateItem(JABBER_LIST_ITEM *pItem, const char *name) { if (!m_bIgnoreRoster || db_get_wsm(pItem->hContact, "CList", "MyHandle").IsEmpty()) { diff --git a/protocols/JabberG/src/stdafx.h b/protocols/JabberG/src/stdafx.h index e744ff7075..a6f1d58f99 100755 --- a/protocols/JabberG/src/stdafx.h +++ b/protocols/JabberG/src/stdafx.h @@ -740,6 +740,7 @@ struct TStringPairs typedef char JabberShaStrBuf[2*MIR_SHA1_HASH_SIZE + 1]; +CMStringA EncodeJid(const char *jid); CMStringA MakeJid(const char *jid, const char *resource); char* JabberNickFromJID(const char *jid); -- cgit v1.2.3