Merge branch 'stable-82x' of ssh://git.citadel.org/appl/gitroot/citadel into stable-82x v8.22
authorArt Cancro <ajc@uncensored.citadel.org>
Sun, 27 Oct 2013 02:52:30 +0000 (22:52 -0400)
committerArt Cancro <ajc@uncensored.citadel.org>
Sun, 27 Oct 2013 02:52:30 +0000 (22:52 -0400)
citadel/modules/smtp/serv_smtpeventclient.c
citadel/modules/smtp/smtp_clienthandlers.c
citadel/modules/smtp/smtp_clienthandlers.h
citadel/modules/xmpp/serv_xmpp.c
libcitadel/buildpackages

index 209c964b2aff885ef03ee8cd0ba6a61f9b37b024..be573d73a33ca23bbd7766a5cb008133a1cbe856 100644 (file)
@@ -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;
index 70373a89623d7a51ed115d600a2196c06e9a4743..bbdbc4684f95131d5e3fa992828ef35da34722ef 100644 (file)
@@ -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,
index dedab4ba49b5c8af79e9ed30bdf40b7e21f8e664..28ffac713863213d91c48049bef3a89220cefabc 100644 (file)
@@ -62,6 +62,7 @@ typedef struct _stmp_out_msg {
        ParsedURL *pCurrRelay;
        StrBuf *msgtext;
        StrBuf *QMsgData;
+       StrBuf *MultiLineBuf;
        const char *envelope_from;
 
        char user[1024];
index 7d8fbc67d02c3349ec864d3d56e916563962fc50..457b2bd459dcb66092426561140a725610a640ea 100644 (file)
@@ -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);
index c446abbb45f0ed1a52e854b5b4c0f2dec6824758..1b31ee8015b2fd3265b4e8812770a88bca30904e 100755 (executable)
@@ -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`