* get synced with citadels mime_parser
authorWilfried Göesgens <willi@citadel.org>
Wed, 14 Feb 2007 20:59:24 +0000 (20:59 +0000)
committerWilfried Göesgens <willi@citadel.org>
Wed, 14 Feb 2007 20:59:24 +0000 (20:59 +0000)
* replace _'s in subjects
* tell what we did to the debs

webcit/debian/changelog
webcit/messages.c
webcit/mime_parser.c

index 7bf865002951491502a7d0a3384b7ef2fea78f6c..89b04874b03dbea80e5c5097f52e9f4d1c8124f3 100644 (file)
@@ -1,3 +1,9 @@
+webcit (7.02-9) unstable; urgency=high
+
+  * fixed some quoted printable bugs. 
+  * thierys fixes to the css
+
+ -- Wilfried Goesgens <citadel@outgesourced.org>  Wed, 14 Feb 2007 21:09:00 +0100
 webcit (7.02-8) unstable; urgency=low
   
   * be more fault tolerant.
index 9e05d552d03a1d2d606ad32ba43519e5faf9b4fa..96fe8cbe36136909859bb5171f57a751ecc69226 100644 (file)
@@ -127,7 +127,18 @@ void utf8ify_rfc822_string(char *buf) {
                        ibuflen = CtdlDecodeBase64(ibuf, istr, strlen(istr));
                }
                else if (!strcasecmp(encoding, "Q")) {  /**< quoted-printable */
-                       ibuflen = CtdlDecodeQuotedPrintable(ibuf, istr, strlen(istr));
+                       size_t len;
+                       long pos;
+                       
+                       len = strlen(istr);
+                       pos = 0;
+                       while (pos < len)
+                       {
+                               if (istr[pos] == '_') istr[pos] = ' ';
+                               pos++;
+                       }
+
+                       ibuflen = CtdlDecodeQuotedPrintable(ibuf, istr, len);
                }
                else {
                        strcpy(ibuf, istr);             /**< unknown encoding */
index 33b249b5062ff3a050dd5532b073e270b550ef11..18b0d97884ea1671d1b4365317b71200c10cea1d 100644 (file)
@@ -49,72 +49,47 @@ char *fixed_partnum(char *supplied_partnum) {
 
 /*
  * Convert "quoted-printable" to binary.  Returns number of bytes decoded.
+ * according to RFC2045 section 6.7
  */
 int CtdlDecodeQuotedPrintable(char *decoded, char *encoded, int sourcelen) {
-       char buf[SIZ];
-       int buf_length = 0;
-       int soft_line_break = 0;
        unsigned int ch;
-       int decoded_length = 0;
-       int i;
+       int destpos = 1;
+       int sourcepos = 1;
+       int ignore_last = 0;
+       char *check;
 
        decoded[0] = 0;
-       decoded_length = 0;
-       memset(buf, '\0', SIZ);
-       buf_length = 0;
-
-       for (i = 0; i < sourcelen; ++i) {
-               size_t buflen = strlen(buf);
-               buf[buf_length++] = encoded[i];
-
-               if ( (encoded[i] == '\n')
-                  || (encoded[i] == 0)
-                  || (i == (sourcelen-1)) ) {
-                       buf[buf_length++] = 0;
-
-                       /*** begin -- process one line ***/
-
-                       if (buf[buflen-1] == '\n') {
-                               buf[buflen-1] = 0;
-                               buflen --;
-                       }
-                       if (buf[buflen-1] == '\r') {
-                               buf[buflen-1] = 0;
-                               buflen --;
-                       }
-                       while (isspace(buf[buflen-1])) {
-                               buf[buflen-1] = 0;
-                               buflen --;
-                       }
-                       soft_line_break = 0;
-
-                       while (buflen > 0) {
-                               if ((buf[0] ==  '=') && (buf[1] == '\0')) {
-                                       soft_line_break = 1;
-                                       buf[0] = '\0';
-                                       buflen = 0;
-                               } else if ((buflen>=3) && (buf[0]=='=')) {
-                                       sscanf(&buf[1], "%02x", &ch);
-                                       decoded[decoded_length++] = ch;
-                                       strcpy(buf, &buf[3]);
-                                       buflen -=3;
-                               } else {
-                                       decoded[decoded_length++] = buf[0];
-                                       strcpy(buf, &buf[1]);
-                                       buflen --;
-                               }
+       if (sourcelen >0)
+               decoded[0] = encoded[0];
+       while (sourcepos <= sourcelen){
+               check = &decoded[destpos];
+               decoded[destpos] = encoded[sourcepos];
+               if ((ignore_last == 0) && (decoded[destpos-1] == '='))
+               {
+                       if ((*check == '\0') || 
+                           (*check == '\n') ||  
+                           (*check == '\r'))
+                       {
+                               decoded[destpos - 1] = '\0';
+                               destpos-=2;
                        }
-                       if (soft_line_break == 0) {
-                               decoded[decoded_length++] = '\r';
-                               decoded[decoded_length++] = '\n';
+                       else if (sourcelen - sourcepos > 2)
+                       {
+                               sscanf(&encoded[sourcepos], "%02x", &ch);
+                               decoded[destpos - 1] = ch;
+                               sourcepos++;
+                               destpos --;
+                               ignore_last = 1;
                        }
-                       buf_length = 0;
-                       /*** end -- process one line ***/
                }
+               else 
+                       ignore_last = 0;
+               destpos ++;
+               sourcepos ++;
        }
 
-       decoded[decoded_length++] = 0;
-       return(decoded_length);
+       decoded[destpos] = 0;
+       return(destpos - 1);
 }
 
 /*