From: Art Cancro Date: Sun, 27 Oct 2013 02:52:30 +0000 (-0400) Subject: Merge branch 'stable-82x' of ssh://git.citadel.org/appl/gitroot/citadel into stable-82x X-Git-Tag: v8.22^0 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=00f5b8d5b752936ff41c54b80ba429a8de313b95;hp=06261a3dcfcee92576600ceeca50011037771873 Merge branch 'stable-82x' of ssh://git.citadel.org/appl/gitroot/citadel into stable-82x --- diff --git a/citadel/modules/smtp/serv_smtpeventclient.c b/citadel/modules/smtp/serv_smtpeventclient.c index 209c964b2..be573d73a 100644 --- a/citadel/modules/smtp/serv_smtpeventclient.c +++ b/citadel/modules/smtp/serv_smtpeventclient.c @@ -127,6 +127,7 @@ void DeleteSmtpOutMsg(void *v) Msg->HostLookup.DNSReplyFree(Msg->HostLookup.VParsedDNSReply); FreeURL(&Msg->Relay); FreeStrBuf(&Msg->msgtext); + FreeStrBuf(&Msg->MultiLineBuf); FreeAsyncIOContents(&Msg->IO); memset (Msg, 0, sizeof(SmtpOutMsg)); /* just to be shure... */ free(Msg); @@ -863,7 +864,16 @@ eReadState SMTP_C_ReadServerStatus(AsyncIO *IO) if (StrLength(IO->IOBuf) < 4) continue; if (ChrPtr(IO->IOBuf)[3] == '-') + { + SmtpOutMsg *Msg; + Msg = (SmtpOutMsg *)IO->Data; + if (Msg->MultiLineBuf == NULL) + Msg->MultiLineBuf = NewStrBuf (); + else + StrBufAppendBufPlain(Msg->MultiLineBuf, HKEY("\n"), 0); + StrBufAppendBuf(Msg->MultiLineBuf, IO->IOBuf, 0); Finished = eBufferNotEmpty; + } else return Finished; break; diff --git a/citadel/modules/smtp/smtp_clienthandlers.c b/citadel/modules/smtp/smtp_clienthandlers.c index 70373a896..bbdbc4684 100644 --- a/citadel/modules/smtp/smtp_clienthandlers.c +++ b/citadel/modules/smtp/smtp_clienthandlers.c @@ -166,6 +166,11 @@ eNextState SMTPC_read_EHLO_reply(SmtpOutMsg *Msg) { if (strstr(ChrPtr(Msg->IO.IOBuf), "LOGIN") != NULL) Msg->SendLogin = 1; + else if ((Msg->MultiLineBuf != NULL) && + strstr(ChrPtr(Msg->MultiLineBuf), "LOGIN") != NULL) + { + Msg->SendLogin = 1; + } } } /* else we fall back to 'helo' */ @@ -321,8 +326,8 @@ eNextState SMTPC_send_authplain_2(SmtpOutMsg *Msg) encodedlen = CtdlEncodeBase64( encoded, - Msg->pCurrRelay->User, - strlen(Msg->pCurrRelay->User), + Msg->pCurrRelay->Pass, + strlen(Msg->pCurrRelay->Pass), 0); StrBufPlain(Msg->IO.SendBuf.Buf, diff --git a/citadel/modules/smtp/smtp_clienthandlers.h b/citadel/modules/smtp/smtp_clienthandlers.h index dedab4ba4..28ffac713 100644 --- a/citadel/modules/smtp/smtp_clienthandlers.h +++ b/citadel/modules/smtp/smtp_clienthandlers.h @@ -62,6 +62,7 @@ typedef struct _stmp_out_msg { ParsedURL *pCurrRelay; StrBuf *msgtext; StrBuf *QMsgData; + StrBuf *MultiLineBuf; const char *envelope_from; char user[1024]; diff --git a/citadel/modules/xmpp/serv_xmpp.c b/citadel/modules/xmpp/serv_xmpp.c index 7d8fbc67d..457b2bd45 100644 --- a/citadel/modules/xmpp/serv_xmpp.c +++ b/citadel/modules/xmpp/serv_xmpp.c @@ -81,6 +81,25 @@ 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; +} /* @@ -93,8 +112,11 @@ static void xmpp_entity_declaration(void *userData, const XML_Char *entityName, 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; @@ -103,6 +125,9 @@ 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 == '<') { @@ -127,10 +152,25 @@ char *xmlesc(char *buf, char *str, int bufsiz) buf[len] = 0; } else { - char oct[10]; - sprintf(oct, "&#%o;", ch); - strcpy(&buf[len], oct); - len += strlen(oct); + 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); + } } if ((len + 6) > bufsiz) { return(buf); diff --git a/libcitadel/buildpackages b/libcitadel/buildpackages index c446abbb4..1b31ee801 100755 --- a/libcitadel/buildpackages +++ b/libcitadel/buildpackages @@ -6,7 +6,7 @@ fi ./bootstrap -export `grep PACKAGE_VERSION= configure |sed -e "s;';;g" -e "s;PACKAGE;LIBCITADEL;" -e "s;3.;;"` +export `grep PACKAGE_VERSION= configure |sed -e "s;';;g" -e "s;PACKAGE;LIBCITADEL;" -e "s;4.;;"` DATE=`date '+%a, %d %b %Y %H:%I:00 %z'` ACTUAL_DIR=`pwd`