Added a from= attribute to the reply to discovery queries. This appears to fix recen...
[citadel.git] / citadel / modules / xmpp / serv_xmpp.c
index 457b2bd459dcb66092426561140a725610a640ea..e23ede887bd2bddf2190356afa4d37c41f584d0a 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * XMPP (Jabber) service for the Citadel system
- * Copyright (c) 2007-2011 by Art Cancro
+ * Copyright (c) 2007-2015 by Art Cancro and citadel.org
  *
  * This program is open source software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -81,25 +81,6 @@ static void xmpp_entity_declaration(void *userData, const XML_Char *entityName,
 }
 #endif
 
-static inline int XMPP_GetUtf8SequenceLength(const char *CharS, const char *CharE)
-{
-       /* if this is is migrated to strbuf, remove this copy. */
-       int n = 0;
-        unsigned char test = (1<<7);
-
-       if ((*CharS & 0xC0) != 0xC0) 
-               return 1;
-
-       while ((n < 8) && 
-              ((test & ((unsigned char)*CharS)) != 0)) 
-       {
-               test = test >> 1;
-               n ++;
-       }
-       if ((n > 6) || ((CharE - CharS) < n))
-               n = 0;
-       return n;
-}
 
 
 /*
@@ -112,11 +93,8 @@ static inline int XMPP_GetUtf8SequenceLength(const char *CharS, const char *Char
 char *xmlesc(char *buf, char *str, int bufsiz)
 {
        char *ptr;
-       char *eiptr;
        unsigned char ch;
-       int inlen;
        int len = 0;
-       int IsUtf8Sequence;
 
        if (!buf) return(NULL);
        buf[0] = 0;
@@ -125,9 +103,6 @@ char *xmlesc(char *buf, char *str, int bufsiz)
                return(buf);
        }
 
-       inlen = strlen(str);
-       eiptr = str + inlen;
-
        for (ptr=str; *ptr; ptr++) {
                ch = *ptr;
                if (ch == '<') {
@@ -152,25 +127,10 @@ char *xmlesc(char *buf, char *str, int bufsiz)
                        buf[len] = 0;
                }
                else {
-                       char oct[32];
-
-                       IsUtf8Sequence =  XMPP_GetUtf8SequenceLength(&buf[len], eiptr);
-                       if (IsUtf8Sequence)
-                       {
-                               while (IsUtf8Sequence > 0){
-                                       buf[len] = *ptr;
-                                       len ++;
-                                       if (--IsUtf8Sequence)
-                                               ptr++;
-                               }
-                               buf[len] = '\0';
-                       }
-                       else
-                       {
-                               sprintf(oct, "&#%o;", ch);
-                               strcpy(&buf[len], oct);
-                               len += strlen(oct);
-                       }
+                       char oct[10];
+                       sprintf(oct, "&#%o;", ch);
+                       strcpy(&buf[len], oct);
+                       len += strlen(oct);
                }
                if ((len + 6) > bufsiz) {
                        return(buf);
@@ -521,6 +481,14 @@ void xmpp_xml_end(void *data, const char *supplied_el) {
                CC->kill_me = KILLME_CLIENT_LOGGED_OUT;
        }
 
+       else if (!strcasecmp(el, "query")) {
+               /* already processed , no further action needed here */
+       }
+
+       else if (!strcasecmp(el, "bind")) {
+               /* already processed , no further action needed here */
+       }
+
        else {
                XMPP_syslog(LOG_DEBUG, "Ignoring unknown tag <%s>\n", el);
        }