@@ -22,6 +22,7 @@ struct mailinfo {
22
22
int use_inbody_headers ;
23
23
const char * metainfo_charset ;
24
24
25
+ struct strbuf charset ;
25
26
char * message_id ;
26
27
enum {
27
28
TE_DONTCARE , TE_QP , TE_BASE64
@@ -31,8 +32,6 @@ struct mailinfo {
31
32
int header_stage ; /* still checking in-body headers? */
32
33
};
33
34
34
-
35
- static struct strbuf charset = STRBUF_INIT ;
36
35
static struct strbuf * * p_hdr_data , * * s_hdr_data ;
37
36
38
37
#define MAX_BOUNDARIES 5
@@ -193,7 +192,7 @@ static struct strbuf *content[MAX_BOUNDARIES];
193
192
194
193
static struct strbuf * * content_top = content ;
195
194
196
- static void handle_content_type (struct strbuf * line )
195
+ static void handle_content_type (struct mailinfo * mi , struct strbuf * line )
197
196
{
198
197
struct strbuf * boundary = xmalloc (sizeof (struct strbuf ));
199
198
strbuf_init (boundary , line -> len );
@@ -207,7 +206,7 @@ static void handle_content_type(struct strbuf *line)
207
206
* content_top = boundary ;
208
207
boundary = NULL ;
209
208
}
210
- slurp_attr (line -> buf , "charset=" , & charset );
209
+ slurp_attr (line -> buf , "charset=" , & mi -> charset );
211
210
212
211
if (boundary ) {
213
212
strbuf_release (boundary );
@@ -504,7 +503,7 @@ static int check_header(struct mailinfo *mi,
504
503
strbuf_add (& sb , line -> buf + len , line -> len - len );
505
504
decode_header (mi , & sb );
506
505
strbuf_insert (& sb , 0 , "Content-Type: " , len );
507
- handle_content_type (& sb );
506
+ handle_content_type (mi , & sb );
508
507
ret = 1 ;
509
508
goto check_header_out ;
510
509
}
@@ -674,7 +673,7 @@ static int handle_commit_msg(struct mailinfo *mi, struct strbuf *line)
674
673
mi -> header_stage = 0 ;
675
674
676
675
/* normalize the log message to UTF-8. */
677
- convert_to_utf8 (mi , line , charset .buf );
676
+ convert_to_utf8 (mi , line , mi -> charset .buf );
678
677
679
678
if (mi -> use_scissors && is_scissors_line (line )) {
680
679
int i ;
@@ -837,7 +836,7 @@ static int handle_boundary(struct mailinfo *mi, struct strbuf *line)
837
836
838
837
/* set some defaults */
839
838
mi -> transfer_encoding = TE_DONTCARE ;
840
- strbuf_reset (& charset );
839
+ strbuf_reset (& mi -> charset );
841
840
842
841
/* slurp in this section's info */
843
842
while (read_one_header_line (line , mi -> input ))
@@ -1024,6 +1023,7 @@ static void setup_mailinfo(struct mailinfo *mi)
1024
1023
memset (mi , 0 , sizeof (* mi ));
1025
1024
strbuf_init (& mi -> name , 0 );
1026
1025
strbuf_init (& mi -> email , 0 );
1026
+ strbuf_init (& mi -> charset , 0 );
1027
1027
mi -> header_stage = 1 ;
1028
1028
mi -> use_inbody_headers = 1 ;
1029
1029
git_config (git_mailinfo_config , & mi );
@@ -1033,6 +1033,7 @@ static void clear_mailinfo(struct mailinfo *mi)
1033
1033
{
1034
1034
strbuf_release (& mi -> name );
1035
1035
strbuf_release (& mi -> email );
1036
+ strbuf_release (& mi -> charset );
1036
1037
free (mi -> message_id );
1037
1038
}
1038
1039
0 commit comments