From bf12e0e79a7b27f6e8688ab031f70449f25b190e Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 25 May 2022 14:29:57 +0300 Subject: Jabber: patch from deadsend to optionally disable XEP-0202 support --- protocols/JabberG/src/jabber_caps.cpp | 4 ++++ protocols/JabberG/src/jabber_iq_handlers.cpp | 19 ++++++++++++------- protocols/JabberG/src/jabber_opt.cpp | 1 + protocols/JabberG/src/jabber_proto.cpp | 1 + protocols/JabberG/src/jabber_proto.h | 1 + 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/protocols/JabberG/src/jabber_caps.cpp b/protocols/JabberG/src/jabber_caps.cpp index af1fa7a768..a4d8767152 100644 --- a/protocols/JabberG/src/jabber_caps.cpp +++ b/protocols/JabberG/src/jabber_caps.cpp @@ -364,6 +364,8 @@ bool CJabberProto::HandleCapsInfoRequest(const TiXmlElement *, CJabberIqInfo *pI if (m_bUseOMEMO) jcb |= JABBER_CAPS_OMEMO_DEVICELIST_NOTIFY; + if (!m_bAllowTimeReplies) + jcb &= ~JABBER_CAPS_ENTITY_TIME; if (!m_bAllowVersionRequests) jcb &= ~JABBER_CAPS_VERSION; @@ -427,6 +429,8 @@ void CJabberProto::UpdateFeatHash() JabberCapsBits jcb = JABBER_CAPS_MIRANDA_ALL; for (auto &it : m_lstJabberFeatCapPairsDynamic) jcb |= it->jcbCap; + if (!m_bAllowTimeReplies) + jcb &= ~JABBER_CAPS_ENTITY_TIME; if (!m_bAllowVersionRequests) jcb &= ~JABBER_CAPS_VERSION; diff --git a/protocols/JabberG/src/jabber_iq_handlers.cpp b/protocols/JabberG/src/jabber_iq_handlers.cpp index 6d0d2e099e..6c02b89986 100644 --- a/protocols/JabberG/src/jabber_iq_handlers.cpp +++ b/protocols/JabberG/src/jabber_iq_handlers.cpp @@ -106,12 +106,14 @@ int GetGMTOffset(void) // entity time (XEP-0202) support bool CJabberProto::OnIqRequestTime(const TiXmlElement*, CJabberIqInfo *pInfo) { - wchar_t stime[100]; - wchar_t szTZ[10]; + if (!m_bAllowTimeReplies) + return false; + wchar_t stime[100]; TimeZone_PrintDateTime(UTC_TIME_HANDLE, L"I", stime, _countof(stime), 0); int nGmtOffset = GetGMTOffset(); + wchar_t szTZ[10]; mir_snwprintf(szTZ, L"%+03d:%02d", nGmtOffset / 60, nGmtOffset % 60); XmlNodeIq iq("result", pInfo); @@ -128,17 +130,20 @@ bool CJabberProto::OnIqRequestTime(const TiXmlElement*, CJabberIqInfo *pInfo) bool CJabberProto::OnIqProcessIqOldTime(const TiXmlElement*, CJabberIqInfo *pInfo) { - struct tm *gmt; - time_t ltime; - char stime[100], *dtime; + if (!m_bAllowTimeReplies) + return false; _tzset(); + time_t ltime; time(<ime); - gmt = gmtime(<ime); + + struct tm *gmt = gmtime(<ime); + + char stime[100]; mir_snprintf(stime, "%.4i%.2i%.2iT%.2i:%.2i:%.2i", gmt->tm_year + 1900, gmt->tm_mon + 1, gmt->tm_mday, gmt->tm_hour, gmt->tm_min, gmt->tm_sec); - dtime = ctime(<ime); + char *dtime = ctime(<ime); dtime[24] = 0; XmlNodeIq iq("result", pInfo); diff --git a/protocols/JabberG/src/jabber_opt.cpp b/protocols/JabberG/src/jabber_opt.cpp index aba6706a61..2b133e56ad 100644 --- a/protocols/JabberG/src/jabber_opt.cpp +++ b/protocols/JabberG/src/jabber_opt.cpp @@ -724,6 +724,7 @@ public: m_options.AddOption(LPGENW("Other"), LPGENW("Embrace picture URLs with [img]"), m_proto->m_bEmbraceUrls); m_options.AddOption(LPGENW("Other"), LPGENW("Ignore server roster (groups and nick names)"), m_proto->m_bIgnoreRoster); + m_options.AddOption(LPGENW("Security"), LPGENW("Allow local time & timezone requests (XEP-0202)"), m_proto->m_bAllowTimeReplies); m_options.AddOption(LPGENW("Security"), LPGENW("Allow servers to request version (XEP-0092)"), m_proto->m_bAllowVersionRequests); m_options.AddOption(LPGENW("Security"), LPGENW("Show information about operating system in version replies"), m_proto->m_bShowOSVersion); m_options.AddOption(LPGENW("Security"), LPGENW("Accept only in band incoming filetransfers (don't disclose own IP)"), m_proto->m_bBsOnlyIBB); diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index fb6fee3ce1..a2ef33798d 100644 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -78,6 +78,7 @@ CJabberProto::CJabberProto(const char *aProtoName, const wchar_t *aUserName) : m_bAcceptHttpAuth(this, "m_bAcceptHttpAuth", true), m_bAcceptNotes(this, "AcceptNotes", true), + m_bAllowTimeReplies(this, "AllowTimeReplies", true), m_bAllowVersionRequests(this, "m_bAllowVersionRequests", true), m_bAutoAcceptAuthorization(this, "AutoAcceptAuthorization", false), m_bAutoAcceptMUC(this, "AutoAcceptMUC", false), diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h index 9d87dbc775..05d8a6f4ee 100644 --- a/protocols/JabberG/src/jabber_proto.h +++ b/protocols/JabberG/src/jabber_proto.h @@ -180,6 +180,7 @@ struct CJabberProto : public PROTO, public IJabberInterface CMOption m_bAcceptHttpAuth; CMOption m_bAcceptNotes; + CMOption m_bAllowTimeReplies; CMOption m_bAllowVersionRequests; CMOption m_bAutoAcceptAuthorization; CMOption m_bAutoAcceptMUC; -- cgit v1.2.3