shithub: xmpp

Download patch

ref: ed2752fe715680692023bbcaf85ddf03c2444c2c
parent: d88eb3a20c49c9d1678847c79a2cc6025ad830da
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Sun Feb 20 16:57:07 EST 2022

preserve original jid verbatim for matching with "to" (thanks binarycat)

--- a/xmpp.c
+++ b/xmpp.c
@@ -21,7 +21,7 @@
 
 int debug, nopresence, nohistory, plainallow;
 Biobuf kbin;
-char *server, *mydomain, *myjid, *mynick, *myresource;
+char *server, *mydomain, *myjid, *mynick, *myresource, *myplainjid;
 static QLock prlock;
 
 static void
@@ -59,7 +59,8 @@
 		return;
 
 	to = xmlgetattr(x->a, "to");
-	if(to != nil && strncmp(to->v, myjid, strlen(myjid)) != 0)
+	if(to != nil && strncmp(to->v, myjid, strlen(myjid)) != 0 && 
+			strncmp(to->v, myplainjid, strlen(myplainjid) != 0))
 		return;
 
 	if((delay = xmlget(x->ch, "delay")) == nil)
@@ -475,6 +476,10 @@
 	if(argc != 1)
 		usage();
 	myjid = strdup(argv[0]);
+	/* myjid will get set later to a value given by the server,
+	 * but sometimes that value isn't used, so we also
+	 * check against the old value */
+	myplainjid = strdup(myjid);
 
 	quotefmtinstall();
 	fmtinstall('H', encodefmt);