mirror of
				https://bitbucket.org/jsuto/piler.git
				synced 2025-10-31 17:42:26 +01:00 
			
		
		
		
	fixed a multiline subject header decoding issue
This commit is contained in:
		| @@ -13,7 +13,7 @@ | |||||||
|  |  | ||||||
| #define VERSION "1.2.0-master" | #define VERSION "1.2.0-master" | ||||||
|  |  | ||||||
| #define BUILD 939 | #define BUILD 940 | ||||||
|  |  | ||||||
| #define HOSTID "mailarchiver" | #define HOSTID "mailarchiver" | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										58
									
								
								src/parser.c
									
									
									
									
									
								
							
							
						
						
									
										58
									
								
								src/parser.c
									
									
									
									
									
								
							| @@ -108,8 +108,6 @@ void post_parse(struct session_data *sdata, struct parser_state *state, struct _ | |||||||
|    clearhash(state->journal_recipient); |    clearhash(state->journal_recipient); | ||||||
|  |  | ||||||
|    trimBuffer(state->b_subject); |    trimBuffer(state->b_subject); | ||||||
|    fixupEncodedHeaderLine(state->b_subject, MAXBUFSIZE); |  | ||||||
|  |  | ||||||
|  |  | ||||||
|    if(sdata->internal_sender == 0) sdata->direction = DIRECTION_INCOMING; |    if(sdata->internal_sender == 0) sdata->direction = DIRECTION_INCOMING; | ||||||
|    else { |    else { | ||||||
| @@ -460,34 +458,36 @@ int parse_line(char *buf, struct parser_state *state, struct session_data *sdata | |||||||
|    } |    } | ||||||
|  |  | ||||||
|  |  | ||||||
|    if(state->is_1st_header == 1 && state->message_state == MSG_SUBJECT && strlen(state->b_subject) + strlen(buf) < MAXBUFSIZE-1){ |  | ||||||
|  |  | ||||||
|       if(state->b_subject[0] == '\0'){ |  | ||||||
|          p = &buf[0]; |  | ||||||
|          if(strncmp(buf, "Subject:", strlen("Subject:")) == 0) p += strlen("Subject:"); |  | ||||||
|          if(*p == ' ') p++; |  | ||||||
|  |  | ||||||
|          strncat(state->b_subject, p, MAXBUFSIZE-strlen(state->b_subject)-1); |  | ||||||
|       } |  | ||||||
|       else { |  | ||||||
|  |  | ||||||
|          /* |  | ||||||
|           * if the next subject line is encoded, then strip the whitespace characters at the beginning of the line |  | ||||||
|           */ |  | ||||||
|  |  | ||||||
|          p = buf; |  | ||||||
|  |  | ||||||
|          if(strcasestr(buf, "?Q?") || strcasestr(buf, "?B?")){ |  | ||||||
|             while(isspace(*p)) p++; |  | ||||||
|          } |  | ||||||
|  |  | ||||||
|          strncat(state->b_subject, p, MAXBUFSIZE-strlen(state->b_subject)-1); |  | ||||||
|       } |  | ||||||
|    } |  | ||||||
|  |  | ||||||
|  |  | ||||||
|    if(state->is_1st_header == 1){ |    if(state->is_1st_header == 1){ | ||||||
|       fixupEncodedHeaderLine(buf, MAXBUFSIZE); |  | ||||||
|  |       if(state->message_state == MSG_SUBJECT && strlen(state->b_subject) + strlen(buf) < MAXBUFSIZE-1){ | ||||||
|  |  | ||||||
|  |          if(state->b_subject[0] == '\0'){ | ||||||
|  |             p = &buf[0]; | ||||||
|  |             if(strncmp(buf, "Subject:", strlen("Subject:")) == 0) p += strlen("Subject:"); | ||||||
|  |             if(*p == ' ') p++; | ||||||
|  |  | ||||||
|  |             fixupEncodedHeaderLine(p, MAXBUFSIZE); | ||||||
|  |             strncat(state->b_subject, p, MAXBUFSIZE-strlen(state->b_subject)-1); | ||||||
|  |          } | ||||||
|  |          else { | ||||||
|  |  | ||||||
|  |             /* | ||||||
|  |              * if the next subject line is encoded, then strip the whitespace characters at the beginning of the line | ||||||
|  |              */ | ||||||
|  |  | ||||||
|  |             p = buf; | ||||||
|  |  | ||||||
|  |             if(strcasestr(buf, "?Q?") || strcasestr(buf, "?B?")){ | ||||||
|  |                while(isspace(*p)) p++; | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             fixupEncodedHeaderLine(p, MAXBUFSIZE); | ||||||
|  |  | ||||||
|  |             strncat(state->b_subject, p, MAXBUFSIZE-strlen(state->b_subject)-1); | ||||||
|  |          } | ||||||
|  |       } | ||||||
|  |       else { fixupEncodedHeaderLine(buf, MAXBUFSIZE); } | ||||||
|    } |    } | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user