comparison src/readpst.c @ 275:e02c81c39232

add some debug code
author Carl Byington <carl@five-ten-sg.com>
date Sun, 22 May 2011 13:16:35 -0700
parents ebcfb23390a4
children bbbd455c0490
comparison
equal deleted inserted replaced
274:ebcfb23390a4 275:e02c81c39232
1358 DEBUG_ENT("write_normal_email"); 1358 DEBUG_ENT("write_normal_email");
1359 1359
1360 pst_convert_utf8_null(item, &item->email->header); 1360 pst_convert_utf8_null(item, &item->email->header);
1361 headers = (item->email->header.str) ? item->email->header.str : *extra_mime_headers; 1361 headers = (item->email->header.str) ? item->email->header.str : *extra_mime_headers;
1362 if (*extra_mime_headers && item->email->header.str) { 1362 if (*extra_mime_headers && item->email->header.str) {
1363 // we have both extra mime headers from outer message, 1363 // we have both extra mime headers from the outer message, and also our own set of headers
1364 // and also our own set of headers 1364 // normally we would use the headers on our current (inner) message, but those
1365 DEBUG_INFO(("Double headers! outer set = \n%s\n\nDouble headers! inner set = \n%s\n", *extra_mime_headers, item->email->header.str)); 1365 // headers are sometimes really bogus - they seem to be fragments of the message body. So
1366 // we only use them if they seem to be actual smtp rfc822 headers.
1367 if ((strncasecmp(headers, "Return-Path: ") == 0) ||
1368 (strncasecmp(headers, "Received: ") == 0) ||
1369 (strncasecmp(headers, "From: ") == 0)) {
1370 }
1371 else {
1372 DEBUG_INFO(("Ignore bogus inner headers = \n%s\n", headers));
1373 headers = *extra_mime_headers;
1374 }
1366 } 1375 }
1367 1376
1368 // setup default body character set and report type 1377 // setup default body character set and report type
1369 strncpy(body_charset, pst_default_charset(item, sizeof(buffer_charset), buffer_charset), sizeof(body_charset)); 1378 strncpy(body_charset, pst_default_charset(item, sizeof(buffer_charset), buffer_charset), sizeof(body_charset));
1370 body_charset[sizeof(body_charset)-1] = '\0'; 1379 body_charset[sizeof(body_charset)-1] = '\0';
1407 if (temp) { 1416 if (temp) {
1408 // cut off our real rfc822 headers here 1417 // cut off our real rfc822 headers here
1409 temp[1] = '\0'; 1418 temp[1] = '\0';
1410 // pointer to all the embedded MIME headers. 1419 // pointer to all the embedded MIME headers.
1411 // we use these to find the actual rfc822 headers for embedded message/rfc822 mime parts 1420 // we use these to find the actual rfc822 headers for embedded message/rfc822 mime parts
1412 *extra_mime_headers = temp+2; 1421 // but only for the outermost message
1422 if (!*extra_mime_headers) *extra_mime_headers = temp+2;
1413 DEBUG_INFO(("Found extra mime headers\n%s\n", temp+2)); 1423 DEBUG_INFO(("Found extra mime headers\n%s\n", temp+2));
1414 } 1424 }
1415 1425
1416 // Check if the headers have all the necessary fields 1426 // Check if the headers have all the necessary fields
1417 header_has_field(headers, "\nFrom: ", &has_from); 1427 header_has_field(headers, "\nFrom: ", &has_from);