summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2022-05-25 14:29:57 +0300
committerGeorge Hazan <ghazan@miranda.im>2022-05-25 14:29:57 +0300
commitbf12e0e79a7b27f6e8688ab031f70449f25b190e (patch)
treebd7929155be134d4b1b99fce8096484dd018456e
parentd46738ce43184a2ca07e00a77859f17698713645 (diff)
Jabber: patch from deadsend to optionally disable XEP-0202 support
-rw-r--r--protocols/JabberG/src/jabber_caps.cpp4
-rw-r--r--protocols/JabberG/src/jabber_iq_handlers.cpp19
-rw-r--r--protocols/JabberG/src/jabber_opt.cpp1
-rw-r--r--protocols/JabberG/src/jabber_proto.cpp1
-rw-r--r--protocols/JabberG/src/jabber_proto.h1
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(&ltime);
- gmt = gmtime(&ltime);
+
+ struct tm *gmt = gmtime(&ltime);
+
+ 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(&ltime);
+ char *dtime = ctime(&ltime);
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<CJabberProto>, public IJabberInterface
CMOption<bool> m_bAcceptHttpAuth;
CMOption<bool> m_bAcceptNotes;
+ CMOption<bool> m_bAllowTimeReplies;
CMOption<bool> m_bAllowVersionRequests;
CMOption<bool> m_bAutoAcceptAuthorization;
CMOption<bool> m_bAutoAcceptMUC;