@@ -22,6 +22,7 @@ struct mailinfo {
2222 int use_inbody_headers ;
2323 const char * metainfo_charset ;
2424
25+ struct strbuf charset ;
2526 char * message_id ;
2627 enum {
2728 TE_DONTCARE , TE_QP , TE_BASE64
@@ -31,8 +32,6 @@ struct mailinfo {
3132 int header_stage ; /* still checking in-body headers? */
3233};
3334
34-
35- static struct strbuf charset = STRBUF_INIT ;
3635static struct strbuf * * p_hdr_data , * * s_hdr_data ;
3736
3837#define MAX_BOUNDARIES 5
@@ -193,7 +192,7 @@ static struct strbuf *content[MAX_BOUNDARIES];
193192
194193static struct strbuf * * content_top = content ;
195194
196- static void handle_content_type (struct strbuf * line )
195+ static void handle_content_type (struct mailinfo * mi , struct strbuf * line )
197196{
198197 struct strbuf * boundary = xmalloc (sizeof (struct strbuf ));
199198 strbuf_init (boundary , line -> len );
@@ -207,7 +206,7 @@ static void handle_content_type(struct strbuf *line)
207206 * content_top = boundary ;
208207 boundary = NULL ;
209208 }
210- slurp_attr (line -> buf , "charset=" , & charset );
209+ slurp_attr (line -> buf , "charset=" , & mi -> charset );
211210
212211 if (boundary ) {
213212 strbuf_release (boundary );
@@ -504,7 +503,7 @@ static int check_header(struct mailinfo *mi,
504503 strbuf_add (& sb , line -> buf + len , line -> len - len );
505504 decode_header (mi , & sb );
506505 strbuf_insert (& sb , 0 , "Content-Type: " , len );
507- handle_content_type (& sb );
506+ handle_content_type (mi , & sb );
508507 ret = 1 ;
509508 goto check_header_out ;
510509 }
@@ -674,7 +673,7 @@ static int handle_commit_msg(struct mailinfo *mi, struct strbuf *line)
674673 mi -> header_stage = 0 ;
675674
676675 /* normalize the log message to UTF-8. */
677- convert_to_utf8 (mi , line , charset .buf );
676+ convert_to_utf8 (mi , line , mi -> charset .buf );
678677
679678 if (mi -> use_scissors && is_scissors_line (line )) {
680679 int i ;
@@ -837,7 +836,7 @@ static int handle_boundary(struct mailinfo *mi, struct strbuf *line)
837836
838837 /* set some defaults */
839838 mi -> transfer_encoding = TE_DONTCARE ;
840- strbuf_reset (& charset );
839+ strbuf_reset (& mi -> charset );
841840
842841 /* slurp in this section's info */
843842 while (read_one_header_line (line , mi -> input ))
@@ -1024,6 +1023,7 @@ static void setup_mailinfo(struct mailinfo *mi)
10241023 memset (mi , 0 , sizeof (* mi ));
10251024 strbuf_init (& mi -> name , 0 );
10261025 strbuf_init (& mi -> email , 0 );
1026+ strbuf_init (& mi -> charset , 0 );
10271027 mi -> header_stage = 1 ;
10281028 mi -> use_inbody_headers = 1 ;
10291029 git_config (git_mailinfo_config , & mi );
@@ -1033,6 +1033,7 @@ static void clear_mailinfo(struct mailinfo *mi)
10331033{
10341034 strbuf_release (& mi -> name );
10351035 strbuf_release (& mi -> email );
1036+ strbuf_release (& mi -> charset );
10361037 free (mi -> message_id );
10371038}
10381039
0 commit comments