X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fmodules%2Fxmpp%2Fserv_xmpp.c;h=64dc8b7aa2f4e723a1d8a75be85e536506a546b1;hb=30ad8940ba800c133c0b1cb66973aaacbf68fe5d;hp=457b2bd459dcb66092426561140a725610a640ea;hpb=292aaf708967cb105ab014d1b4e5fe4ab0b342d8;p=citadel.git diff --git a/citadel/modules/xmpp/serv_xmpp.c b/citadel/modules/xmpp/serv_xmpp.c index 457b2bd45..64dc8b7aa 100644 --- a/citadel/modules/xmpp/serv_xmpp.c +++ b/citadel/modules/xmpp/serv_xmpp.c @@ -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,9 +81,15 @@ static void xmpp_entity_declaration(void *userData, const XML_Char *entityName, } #endif -static inline int XMPP_GetUtf8SequenceLength(const char *CharS, const char *CharE) + + +/* + * Given a source string and a target buffer, returns the string + * properly escaped for insertion into an XML stream. Returns a + * pointer to the target buffer for convenience. + */ +static inline int Ctdl_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); @@ -101,22 +107,13 @@ static inline int XMPP_GetUtf8SequenceLength(const char *CharS, const char *Char return n; } - -/* - * Given a source string and a target buffer, returns the string - * properly escaped for insertion into an XML stream. Returns a - * pointer to the target buffer for convenience. - * - * BUG: this does not properly handle UTF-8 - */ char *xmlesc(char *buf, char *str, int bufsiz) { - char *ptr; - char *eiptr; + int IsUtf8Sequence; + char *ptr, *pche; unsigned char ch; int inlen; int len = 0; - int IsUtf8Sequence; if (!buf) return(NULL); buf[0] = 0; @@ -124,9 +121,8 @@ char *xmlesc(char *buf, char *str, int bufsiz) if (!str) { return(buf); } - inlen = strlen(str); - eiptr = str + inlen; + pche = str + inlen; for (ptr=str; *ptr; ptr++) { ch = *ptr; @@ -152,21 +148,20 @@ char *xmlesc(char *buf, char *str, int bufsiz) buf[len] = 0; } else { - char oct[32]; - - IsUtf8Sequence = XMPP_GetUtf8SequenceLength(&buf[len], eiptr); + IsUtf8Sequence = Ctdl_GetUtf8SequenceLength(ptr, pche); if (IsUtf8Sequence) { - while (IsUtf8Sequence > 0){ + while ((IsUtf8Sequence > 0) && + (ptr < pche)) + { buf[len] = *ptr; - len ++; - if (--IsUtf8Sequence) - ptr++; + ptr ++; + --IsUtf8Sequence; } - buf[len] = '\0'; } else { + char oct[10]; sprintf(oct, "&#%o;", ch); strcpy(&buf[len], oct); len += strlen(oct); @@ -521,6 +516,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); }