View | Details | Raw Unified | Return to bug 72801
Collapse All | Expand All

(-)sylpheed-0.9.4claws/src/codeconv.c (-6 / +8 lines)
Lines 1352-1358 const gchar *conv_get_current_locale(voi Link Here
1352
	return cur_locale;
1352
	return cur_locale;
1353
}
1353
}
1354
1354
1355
void conv_unmime_header_overwrite(gchar *str)
1355
void conv_unmime_header_overwrite(gchar *str, gint strsize)
1356
{
1356
{
1357
	gchar *buf;
1357
	gchar *buf;
1358
	gint buflen;
1358
	gint buflen;
Lines 1364-1375 void conv_unmime_header_overwrite(gchar Link Here
1364
		buflen = strlen(str) * 2 + 1;
1364
		buflen = strlen(str) * 2 + 1;
1365
		Xalloca(buf, buflen, return);
1365
		Xalloca(buf, buflen, return);
1366
		conv_anytodisp(buf, buflen, str);
1366
		conv_anytodisp(buf, buflen, str);
1367
		unmime_header(str, buf);
1367
		unmime_header(str, strsize, buf);
1368
	} else {
1368
	} else {
1369
		buflen = strlen(str) + 1;
1369
		buflen = strlen(str) + 1;
1370
		Xalloca(buf, buflen, return);
1370
		Xalloca(buf, buflen, return);
1371
		unmime_header(buf, str);
1371
		unmime_header(buf, buflen, str);
1372
		strncpy2(str, buf, buflen);
1372
		strncpy2(str, buf, strsize);
1373
	}
1373
	}
1374
}
1374
}
1375
1375
Lines 1378-1383 void conv_unmime_header(gchar *outbuf, g Link Here
1378
{
1378
{
1379
	CharSet cur_charset;
1379
	CharSet cur_charset;
1380
1380
1381
	g_return_if_fail(str != NULL);
1382
1381
	cur_charset = conv_get_current_charset();
1383
	cur_charset = conv_get_current_charset();
1382
1384
1383
	if (cur_charset == C_EUC_JP) {
1385
	if (cur_charset == C_EUC_JP) {
Lines 1387-1395 void conv_unmime_header(gchar *outbuf, g Link Here
1387
		buflen = strlen(str) * 2 + 1;
1389
		buflen = strlen(str) * 2 + 1;
1388
		Xalloca(buf, buflen, return);
1390
		Xalloca(buf, buflen, return);
1389
		conv_anytodisp(buf, buflen, str);
1391
		conv_anytodisp(buf, buflen, str);
1390
		unmime_header(outbuf, buf);
1392
		unmime_header(outbuf, outlen, buf);
1391
	} else
1393
	} else
1392
		unmime_header(outbuf, str);
1394
		unmime_header(outbuf, outlen, str);
1393
}
1395
}
1394
1396
1395
#define MAX_LINELEN		76
1397
#define MAX_LINELEN		76
(-)sylpheed-0.9.4claws/src/codeconv.h (-1 / +1 lines)
Lines 214-220 gboolean conv_is_multibyte_encoding (Ch Link Here
214
214
215
const gchar *conv_get_current_locale		(void);
215
const gchar *conv_get_current_locale		(void);
216
216
217
void conv_unmime_header_overwrite	(gchar		*str);
217
void conv_unmime_header_overwrite	(gchar		*str, gint strsize);
218
void conv_unmime_header			(gchar		*outbuf,
218
void conv_unmime_header			(gchar		*outbuf,
219
					 gint		 outlen,
219
					 gint		 outlen,
220
					 const gchar	*str,
220
					 const gchar	*str,
(-)sylpheed-0.9.4claws/src/compose.c (-5 / +5 lines)
Lines 1548-1559 static gint compose_parse_header(Compose Link Here
1548
	fclose(fp);
1548
	fclose(fp);
1549
1549
1550
	if (hentry[H_REPLY_TO].body != NULL) {
1550
	if (hentry[H_REPLY_TO].body != NULL) {
1551
		conv_unmime_header_overwrite(hentry[H_REPLY_TO].body);
1551
		conv_unmime_header_overwrite(hentry[H_REPLY_TO].body, strlen(hentry[H_REPLY_TO].body));
1552
		compose->replyto = hentry[H_REPLY_TO].body;
1552
		compose->replyto = hentry[H_REPLY_TO].body;
1553
		hentry[H_REPLY_TO].body = NULL;
1553
		hentry[H_REPLY_TO].body = NULL;
1554
	}
1554
	}
1555
	if (hentry[H_CC].body != NULL) {
1555
	if (hentry[H_CC].body != NULL) {
1556
		conv_unmime_header_overwrite(hentry[H_CC].body);
1556
		conv_unmime_header_overwrite(hentry[H_CC].body, strlen(hentry[H_CC].body));
1557
		compose->cc = hentry[H_CC].body;
1557
		compose->cc = hentry[H_CC].body;
1558
		hentry[H_CC].body = NULL;
1558
		hentry[H_CC].body = NULL;
1559
	}
1559
	}
Lines 1569-1587 static gint compose_parse_header(Compose Link Here
1569
	}
1569
	}
1570
	if (hentry[H_BCC].body != NULL) {
1570
	if (hentry[H_BCC].body != NULL) {
1571
		if (compose->mode == COMPOSE_REEDIT) {
1571
		if (compose->mode == COMPOSE_REEDIT) {
1572
			conv_unmime_header_overwrite(hentry[H_BCC].body);
1572
			conv_unmime_header_overwrite(hentry[H_BCC].body, strlen(hentry[H_BCC].body));
1573
			compose->bcc = hentry[H_BCC].body;
1573
			compose->bcc = hentry[H_BCC].body;
1574
		} else
1574
		} else
1575
			g_free(hentry[H_BCC].body);
1575
			g_free(hentry[H_BCC].body);
1576
		hentry[H_BCC].body = NULL;
1576
		hentry[H_BCC].body = NULL;
1577
	}
1577
	}
1578
	if (hentry[H_NEWSGROUPS].body != NULL) {
1578
	if (hentry[H_NEWSGROUPS].body != NULL) {
1579
		conv_unmime_header_overwrite(hentry[H_NEWSGROUPS].body);
1579
		conv_unmime_header_overwrite(hentry[H_NEWSGROUPS].body, strlen(hentry[H_NEWSGROUPS].body));
1580
		compose->newsgroups = hentry[H_NEWSGROUPS].body;
1580
		compose->newsgroups = hentry[H_NEWSGROUPS].body;
1581
		hentry[H_NEWSGROUPS].body = NULL;
1581
		hentry[H_NEWSGROUPS].body = NULL;
1582
	}
1582
	}
1583
	if (hentry[H_FOLLOWUP_TO].body != NULL) {
1583
	if (hentry[H_FOLLOWUP_TO].body != NULL) {
1584
		conv_unmime_header_overwrite(hentry[H_FOLLOWUP_TO].body);
1584
		conv_unmime_header_overwrite(hentry[H_FOLLOWUP_TO].body, strlen(hentry[H_FOLLOWUP_TO].body));
1585
		compose->followup_to = hentry[H_FOLLOWUP_TO].body;
1585
		compose->followup_to = hentry[H_FOLLOWUP_TO].body;
1586
		hentry[H_FOLLOWUP_TO].body = NULL;
1586
		hentry[H_FOLLOWUP_TO].body = NULL;
1587
	}
1587
	}
(-)sylpheed-0.9.4claws/src/procmime.c (-10 / +5 lines)
Lines 400-411 void procmime_scan_content_type(MimeInfo Link Here
400
			if (!strcasecmp(attr, "charset"))
400
			if (!strcasecmp(attr, "charset"))
401
				mimeinfo->charset = g_strdup(value);
401
				mimeinfo->charset = g_strdup(value);
402
			else if (!strcasecmp(attr, "name")) {
402
			else if (!strcasecmp(attr, "name")) {
403
				gchar *tmp;
403
				gchar tmp[BUFFSIZE];
404
				size_t len;
405
404
406
				len = strlen(value) + 1;
405
				conv_unmime_header(tmp, sizeof(tmp), value, NULL);
407
				Xalloca(tmp, len, return);
408
				conv_unmime_header(tmp, len, value, NULL);
409
				g_free(mimeinfo->name);
406
				g_free(mimeinfo->name);
410
				/*pgp signatures should NOT have a name */
407
				/*pgp signatures should NOT have a name */
411
				if (mimeinfo->content_type 
408
				if (mimeinfo->content_type 
Lines 467-478 void procmime_scan_content_disposition(M Link Here
467
464
468
		if (*value) {
465
		if (*value) {
469
			if (!strcasecmp(attr, "filename")) {
466
			if (!strcasecmp(attr, "filename")) {
470
				gchar *tmp;
467
				gchar tmp[BUFFSIZE];
471
				size_t len;
472
468
473
				len = strlen(value) + 1;
469
				conv_unmime_header(tmp, sizeof(tmp), value,
474
				Xalloca(tmp, len, return);
470
						   NULL);
475
				conv_unmime_header(tmp, len, value, NULL);
476
				g_free(mimeinfo->filename);
471
				g_free(mimeinfo->filename);
477
				/*pgp signatures should NOT have a name */
472
				/*pgp signatures should NOT have a name */
478
				if (mimeinfo->content_type 
473
				if (mimeinfo->content_type 
(-)sylpheed-0.9.4claws/src/textview.c (+2 lines)
Lines 697-702 static void textview_show_html(TextView Link Here
697
	        } else
697
	        } else
698
		        textview_write_line(textview, str, NULL);
698
		        textview_write_line(textview, str, NULL);
699
	}
699
	}
700
	textview_write_line(textview, "\n", NULL);
701
700
	html_parser_destroy(parser);
702
	html_parser_destroy(parser);
701
}
703
}
702
704
(-)sylpheed-0.9.4claws/src/unmime.c (-5 / +33 lines)
Lines 28-40 Link Here
28
#include "codeconv.h"
28
#include "codeconv.h"
29
#include "base64.h"
29
#include "base64.h"
30
#include "quoted-printable.h"
30
#include "quoted-printable.h"
31
#include "utils.h"
31
32
32
#define ENCODED_WORD_BEGIN	"=?"
33
#define ENCODED_WORD_BEGIN	"=?"
33
#define ENCODED_WORD_END	"?="
34
#define ENCODED_WORD_END	"?="
34
35
35
/* Decodes headers based on RFC2045 and RFC2047. */
36
/* Decodes headers based on RFC2045 and RFC2047. */
36
37
37
void unmime_header(gchar *out, const gchar *str)
38
void unmime_header(gchar *out, gint outlen, const gchar *str)
38
{
39
{
39
	const gchar *p = str;
40
	const gchar *p = str;
40
	gchar *outp = out;
41
	gchar *outp = out;
Lines 51-85 void unmime_header(gchar *out, const gch Link Here
51
52
52
		eword_begin_p = strstr(p, ENCODED_WORD_BEGIN);
53
		eword_begin_p = strstr(p, ENCODED_WORD_BEGIN);
53
		if (!eword_begin_p) {
54
		if (!eword_begin_p) {
54
			strcpy(outp, p);
55
			strncpy2(outp, p, outlen);
55
			return;
56
			return;
56
		}
57
		}
57
		encoding_begin_p = strchr(eword_begin_p + 2, '?');
58
		encoding_begin_p = strchr(eword_begin_p + 2, '?');
58
		if (!encoding_begin_p) {
59
		if (!encoding_begin_p) {
59
			strcpy(outp, p);
60
			strncpy2(outp, p, outlen);
60
			return;
61
			return;
61
		}
62
		}
62
		text_begin_p = strchr(encoding_begin_p + 1, '?');
63
		text_begin_p = strchr(encoding_begin_p + 1, '?');
63
		if (!text_begin_p) {
64
		if (!text_begin_p) {
64
			strcpy(outp, p);
65
			strncpy2(outp, p, outlen);
65
			return;
66
			return;
66
		}
67
		}
67
		eword_end_p = strstr(text_begin_p + 1, ENCODED_WORD_END);
68
		eword_end_p = strstr(text_begin_p + 1, ENCODED_WORD_END);
68
		if (!eword_end_p) {
69
		if (!eword_end_p) {
69
			strcpy(outp, p);
70
			strncpy2(outp, p, outlen);
70
			return;
71
			return;
71
		}
72
		}
72
73
73
		if (p == str) {
74
		if (p == str) {
75
			if (eword_begin_p - p > outlen - 1) {
76
				strncpy2(outp, p, outlen);
77
				return;
78
			}
74
			memcpy(outp, p, eword_begin_p - p);
79
			memcpy(outp, p, eword_begin_p - p);
75
			outp += eword_begin_p - p;
80
			outp += eword_begin_p - p;
81
			outlen -= eword_begin_p - p;
76
			p = eword_begin_p;
82
			p = eword_begin_p;
77
		} else {
83
		} else {
78
			/* ignore spaces between encoded words */
84
			/* ignore spaces between encoded words */
79
			for (sp = p; sp < eword_begin_p; sp++) {
85
			for (sp = p; sp < eword_begin_p; sp++) {
80
				if (!isspace(*sp)) {
86
				if (!isspace(*sp)) {
87
					if (eword_begin_p - p > outlen - 1) {
88
						strncpy2(outp, p, outlen);
89
						return;
90
					}
81
					memcpy(outp, p, eword_begin_p - p);
91
					memcpy(outp, p, eword_begin_p - p);
82
					outp += eword_begin_p - p;
92
					outp += eword_begin_p - p;
93
					outlen -= eword_begin_p - p;
83
					p = eword_begin_p;
94
					p = eword_begin_p;
84
					break;
95
					break;
85
				}
96
				}
Lines 105-112 void unmime_header(gchar *out, const gch Link Here
105
				(decoded_text, text_begin_p + 1,
116
				(decoded_text, text_begin_p + 1,
106
				 eword_end_p - (text_begin_p + 1));
117
				 eword_end_p - (text_begin_p + 1));
107
		} else {
118
		} else {
119
			if (eword_end_p + 2 - p > outlen - 1) {
120
				strncpy2(outp, p, outlen);
121
				return;
122
			}
108
			memcpy(outp, p, eword_end_p + 2 - p);
123
			memcpy(outp, p, eword_end_p + 2 - p);
109
			outp += eword_end_p + 2 - p;
124
			outp += eword_end_p + 2 - p;
125
			outlen -= eword_end_p + 2 - p;
110
			p = eword_end_p + 2;
126
			p = eword_end_p + 2;
111
			continue;
127
			continue;
112
		}
128
		}
Lines 115-127 void unmime_header(gchar *out, const gch Link Here
115
		conv_str = conv_codeset_strdup(decoded_text, charset, NULL);
131
		conv_str = conv_codeset_strdup(decoded_text, charset, NULL);
116
		if (conv_str) {
132
		if (conv_str) {
117
			len = strlen(conv_str);
133
			len = strlen(conv_str);
134
			if (len > outlen - 1) {
135
				strncpy2(outp, conv_str, outlen);
136
				g_free(conv_str);
137
				g_free(decoded_text);
138
				return;
139
			}
118
			memcpy(outp, conv_str, len);
140
			memcpy(outp, conv_str, len);
119
			g_free(conv_str);
141
			g_free(conv_str);
120
		} else {
142
		} else {
121
			len = strlen(decoded_text);
143
			len = strlen(decoded_text);
144
			if (len > outlen - 1) {
145
				conv_localetodisp(outp, outlen, decoded_text);
146
				g_free(decoded_text);
147
				return;
148
			}
122
			conv_localetodisp(outp, len + 1, decoded_text);
149
			conv_localetodisp(outp, len + 1, decoded_text);
123
		}
150
		}
124
		outp += len;
151
		outp += len;
152
		outlen -= len;
125
153
126
		g_free(decoded_text);
154
		g_free(decoded_text);
127
155
(-)sylpheed-0.9.4claws/src/unmime.h (+1 lines)
Lines 23-28 Link Here
23
#include <glib.h>
23
#include <glib.h>
24
24
25
void unmime_header			(gchar		*out,
25
void unmime_header			(gchar		*out,
26
					 gint		 len,
26
					 const gchar	*str);
27
					 const gchar	*str);
27
gint unmime_quoted_printable_line	(gchar		*str);
28
gint unmime_quoted_printable_line	(gchar		*str);
28
29

Return to bug 72801