conv_encode_header(): fix bug when long headers with 8-bit characters are used
authorPaul Mangan <paul@claws-mail.org>
Sat, 25 Jan 2003 00:46:20 +0000 (00:46 +0000)
committerPaul Mangan <paul@claws-mail.org>
Sat, 25 Jan 2003 00:46:20 +0000 (00:46 +0000)
configure.ac
src/codeconv.c

index aba4f2f..3dcbd2a 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=9
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws
+EXTRA_VERSION=claws1
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 25c0e38..166e530 100644 (file)
@@ -1044,7 +1044,7 @@ void conv_unmime_header(gchar *outbuf, gint outlen, const gchar *str,
 
 #define B64LEN(len)    ((len) / 3 * 4 + ((len) % 3 ? 4 : 0))
 
-#define LBREAK_IF_REQUIRED(cond)                               \
+#define LBREAK_IF_REQUIRED(cond, plaintext)                    \
 {                                                              \
        if (len - (destp - dest) < MAX_LINELEN + 2) {           \
                *destp = '\0';                                  \
@@ -1054,7 +1054,7 @@ void conv_unmime_header(gchar *outbuf, gint outlen, const gchar *str,
        if ((cond) && *srcp) {                                  \
                if (destp > dest && isspace(*(destp - 1)))      \
                        destp--;                                \
-               else if (isspace(*srcp))                        \
+               else if (plaintext && isspace(*srcp))           \
                        srcp++;                                 \
                if (*srcp) {                                    \
                        *destp++ = '\n';                        \
@@ -1097,12 +1097,12 @@ void conv_encode_header(gchar *dest, gint len, const gchar *src,
        left = MAX_LINELEN - header_len;
 
        while (*srcp) {
-               LBREAK_IF_REQUIRED(left <= 0);
+               LBREAK_IF_REQUIRED(left <= 0, TRUE);
 
                while (isspace(*srcp)) {
                        *destp++ = *srcp++;
                        left--;
-                       LBREAK_IF_REQUIRED(left <= 0);
+                       LBREAK_IF_REQUIRED(left <= 0, TRUE);
                }
 
                /* output as it is if the next word is ASCII string */
@@ -1110,9 +1110,9 @@ void conv_encode_header(gchar *dest, gint len, const gchar *src,
                        gint word_len;
 
                        word_len = get_next_word_len(srcp);
-                       LBREAK_IF_REQUIRED(left < word_len);
+                       LBREAK_IF_REQUIRED(left < word_len, TRUE);
                        while (word_len > 0) {
-                               LBREAK_IF_REQUIRED(left <= 0);
+                               LBREAK_IF_REQUIRED(left <= 0, TRUE);
                                *destp++ = *srcp++;
                                left--;
                                word_len--;
@@ -1167,7 +1167,7 @@ void conv_encode_header(gchar *dest, gint len, const gchar *src,
                                        cur_len += mb_len;
                                        p += mb_len;
                                } else if (cur_len == 0) {
-                                       LBREAK_IF_REQUIRED(1);
+                                       LBREAK_IF_REQUIRED(1, FALSE);
                                        continue;
                                } else {
                                        cont = TRUE;
@@ -1210,7 +1210,7 @@ void conv_encode_header(gchar *dest, gint len, const gchar *src,
                                left -= mime_block_len;
                        }
 
-                       LBREAK_IF_REQUIRED(cont);
+                       LBREAK_IF_REQUIRED(cont, FALSE);
 
                        if (cur_len == 0)
                                break;