comparison src/readpst.c @ 365:e4c414ff8fa2

allow first internet header to be wrapped
author Carl Byington <carl@five-ten-sg.com>
date Tue, 30 Aug 2016 15:04:12 -0700
parents 3a1d25c579c6
children 67a3ee227495
comparison
equal deleted inserted replaced
364:9c6f93aca0db 365:e4c414ff8fa2
1212 fprintf(f_output, "\n\n"); 1212 fprintf(f_output, "\n\n");
1213 DEBUG_RET(); 1213 DEBUG_RET();
1214 } 1214 }
1215 1215
1216 1216
1217 int header_match(char *header, char*field) {
1218 int n = strlen(field);
1219 if (strncasecmp(header, field, n) == 0) return 1; // tag:{space}
1220 if ((field[n-1] == ' ') && (strncasecmp(header, field, n-1) == 0)) {
1221 char *crlftab = "\r\n\t";
1222 DEBUG_INFO(("Possible wrapped header = %s\n", header));
1223 if (strncasecmp(header+n-1, crlftab, 3) == 0) return 1; // tag:{cr}{lf}{tab}
1224 }
1225 return 0;
1226 }
1227
1217 int valid_headers(char *header) 1228 int valid_headers(char *header)
1218 { 1229 {
1219 // headers are sometimes really bogus - they seem to be fragments of the 1230 // headers are sometimes really bogus - they seem to be fragments of the
1220 // message body, so we only use them if they seem to be real rfc822 headers. 1231 // message body, so we only use them if they seem to be real rfc822 headers.
1221 // this list is composed of ones that we have seen in real pst files. 1232 // this list is composed of ones that we have seen in real pst files.
1222 // there are surely others. the problem is - given an arbitrary character 1233 // there are surely others. the problem is - given an arbitrary character
1223 // string, is it a valid (or even reasonable) set of rfc822 headers? 1234 // string, is it a valid (or even reasonable) set of rfc822 headers?
1224 if (header) { 1235 if (header) {
1225 if ((strncasecmp(header, "Content-Type: ", 14) == 0) || 1236 if (header_match(header, "Content-Type: " )) return 1;
1226 (strncasecmp(header, "Date: ", 6) == 0) || 1237 if (header_match(header, "Date: " )) return 1;
1227 (strncasecmp(header, "From: ", 6) == 0) || 1238 if (header_match(header, "From: " )) return 1;
1228 (strncasecmp(header, "MIME-Version: ", 14) == 0) || 1239 if (header_match(header, "MIME-Version: " )) return 1;
1229 (strncasecmp(header, "Microsoft Mail Internet Headers", 31) == 0) || 1240 if (header_match(header, "Microsoft Mail Internet Headers")) return 1;
1230 (strncasecmp(header, "Received: ", 10) == 0) || 1241 if (header_match(header, "Received: " )) return 1;
1231 (strncasecmp(header, "Return-Path: ", 13) == 0) || 1242 if (header_match(header, "Return-Path: " )) return 1;
1232 (strncasecmp(header, "Subject: ", 9) == 0) || 1243 if (header_match(header, "Subject: " )) return 1;
1233 (strncasecmp(header, "To: ", 4) == 0) || 1244 if (header_match(header, "To: " )) return 1;
1234 (strncasecmp(header, "X-ASG-Debug-ID: ", 16) == 0) || 1245 if (header_match(header, "X-ASG-Debug-ID: " )) return 1;
1235 (strncasecmp(header, "X-Barracuda-URL: ", 17) == 0) || 1246 if (header_match(header, "X-Barracuda-URL: " )) return 1;
1236 (strncasecmp(header, "X-x: ", 5) == 0)) { 1247 if (header_match(header, "X-x: " )) return 1;
1237 return 1; 1248 if (strlen(header) > 2) {
1238 } 1249 DEBUG_INFO(("Ignore bogus headers = %s\n", header));
1239 else { 1250 }
1240 if (strlen(header) > 2) { 1251 return 0;
1241 DEBUG_INFO(("Ignore bogus headers = %s\n", header));
1242 }
1243 return 0;
1244 }
1245 } 1252 }
1246 else return 0; 1253 else return 0;
1247 } 1254 }
1248 1255
1249 1256