projects
/
claws.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
conv_encode_header(): fix bug when long headers with 8-bit characters are used
[claws.git]
/
src
/
codeconv.c
diff --git
a/src/codeconv.c
b/src/codeconv.c
index 25c0e38d1f7a092610618cef297ac454a5fd6f44..166e5307308a620379f72c935c14d8b195bd46e2 100644
(file)
--- a/
src/codeconv.c
+++ b/
src/codeconv.c
@@
-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 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'; \
{ \
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--; \
if ((cond) && *srcp) { \
if (destp > dest && isspace(*(destp - 1))) \
destp--; \
- else if (
isspace(*srcp))
\
+ else if (
plaintext && isspace(*srcp))
\
srcp++; \
if (*srcp) { \
*destp++ = '\n'; \
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) {
left = MAX_LINELEN - header_len;
while (*srcp) {
- LBREAK_IF_REQUIRED(left <= 0);
+ LBREAK_IF_REQUIRED(left <= 0
, TRUE
);
while (isspace(*srcp)) {
*destp++ = *srcp++;
left--;
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 */
}
/* 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);
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) {
while (word_len > 0) {
- LBREAK_IF_REQUIRED(left <= 0);
+ LBREAK_IF_REQUIRED(left <= 0
, TRUE
);
*destp++ = *srcp++;
left--;
word_len--;
*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) {
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;
continue;
} else {
cont = TRUE;
@@
-1210,7
+1210,7
@@
void conv_encode_header(gchar *dest, gint len, const gchar *src,
left -= mime_block_len;
}
left -= mime_block_len;
}
- LBREAK_IF_REQUIRED(cont);
+ LBREAK_IF_REQUIRED(cont
, FALSE
);
if (cur_len == 0)
break;
if (cur_len == 0)
break;