changeset 139:1b3922080ca8

add forensic headers to capture some other data of interest; switch back to quoted From separator line
author Carl Byington <carl@five-ten-sg.com>
date Sun, 08 Feb 2009 20:20:34 -0800
parents 4b8c2c8a5829
children fc6c54c453e5
files ChangeLog TODO regression/regression-tests.bash src/readpst.c
diffstat 4 files changed, 30 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Feb 07 10:26:56 2009 -0800
+++ b/ChangeLog	Sun Feb 08 20:20:34 2009 -0800
@@ -1,3 +1,8 @@
+LibPST 0.6.28 (2009-xx-xx)
+===============================
+    * add X-libpst-forensic-* headers to capture items of interest
+      that are not used by normal mail clients.
+
 LibPST 0.6.27 (2009-02-07)
 ===============================
     * fix for const correctness on Fedora 11
--- a/TODO	Sat Feb 07 10:26:56 2009 -0800
+++ b/TODO	Sun Feb 08 20:20:34 2009 -0800
@@ -2,5 +2,5 @@
 Need testing on big-endian machines. We may be missing some LEnn_CPU()
 calls.
 
-The debug log code, and readpstlog, needs large file support to handle
-debug files larger than 2GB.
+pst2diii needs header and mime type updates from readpst.
+
--- a/regression/regression-tests.bash	Sat Feb 07 10:26:56 2009 -0800
+++ b/regression/regression-tests.bash	Sun Feb 08 20:20:34 2009 -0800
@@ -23,7 +23,7 @@
     mkdir output$n
     #    ../src/readpst -cv -o output$n $fn >$ba.err 2>&1
     $val ../src/readpst -cv -o output$n -d dumper $fn >$ba.err 2>&1
-    #readpst -cv -o output$n -d dumper $fn >$ba.err 2>&1
+    #           readpst -cv -o output$n -d dumper $fn >$ba.err 2>&1
          ../src/readpstlog -f I dumper >$ba.log
     #$val ../src/pst2ldif -d dumper -b 'o=ams-cc.com, c=US' -c 'newPerson' -o $fn >$ba.ldif.err 2>&1
     #$val ../src/pst2ldif -d dumper -b 'o=ams-cc.com, c=US' -c 'inetOrgPerson' $fn >$ba.ldif2.err 2>&1
--- a/src/readpst.c	Sat Feb 07 10:26:56 2009 -0800
+++ b/src/readpst.c	Sun Feb 08 20:20:34 2009 -0800
@@ -919,8 +919,8 @@
     int attach_num;
     time_t em_time;
     char *c_time;
-    int has_from, has_subject, has_to, has_cc, has_bcc, has_date;
-    has_from = has_subject = has_to = has_cc = has_bcc = has_date = 0;
+    int has_from, has_subject, has_to, has_cc, has_date;
+    has_from = has_subject = has_to = has_cc = has_date = 0;
     DEBUG_ENT("write_normal_email");
 
     // setup default body character set
@@ -970,7 +970,6 @@
         header_has_field(item->email->header, "\nSubject: ", &has_subject);
         header_has_field(item->email->header, "\nDate: ",    &has_date);
         header_has_field(item->email->header, "\nCC: ",      &has_cc);
-        header_has_field(item->email->header, "\nBCC: ",     &has_bcc);
 
         // look for charset in Content-Type header
         t = header_get_field(item->email->header, "\nContent-Type: ");
@@ -1024,7 +1023,8 @@
         header_strip_field(item->email->header, "\nContent-Transfer-Encoding: ");
         header_strip_field(item->email->header, "\nContent-class: ");
         header_strip_field(item->email->header, "\nX-MimeOLE: ");
-        header_strip_field(item->email->header, "\nBcc: ");
+        header_strip_field(item->email->header, "\nBcc:");
+        header_strip_field(item->email->header, "\nX-From_: ");
     }
 
     DEBUG_EMAIL(("About to print Header\n"));
@@ -1033,30 +1033,17 @@
         DEBUG_EMAIL(("item->email->subject->subj = %s\n", item->email->subject->subj));
     }
 
+    if (mode != MODE_SEPARATE) {
+        // most modes need this separator line
+        fprintf(f_output, "From \"%s\" %s\n", sender, c_time);
+    }
+
     if (item->email->header) {
         int len;
-        char *soh = item->email->header;
-
-        if (mode != MODE_SEPARATE) {
-            // don't put rubbish in if we are doing separate
-            if (strncmp(soh, "X-From_: ", 9) == 0 ) {
-                fputs("From ", f_output);
-                soh += 9;
-            } else
-                fprintf(f_output, "From %s %s\n", sender, c_time);
-        }
-
+        fprintf(f_output, "%s", item->email->header);
         // make sure the headers end with a \n
-        fprintf(f_output, "%s", soh);
-        len = strlen(soh);
-        if (!len || (soh[len-1] != '\n')) fprintf(f_output, "\n");
-
-    } else {
-        //make up our own headers
-        if (mode != MODE_SEPARATE) {
-            // don't want this first line for this mode
-            fprintf(f_output, "From %s %s\n", sender, c_time);
-        }
+        len = strlen(item->email->header);
+        if (!len || (item->email->header[len-1] != '\n')) fprintf(f_output, "\n");
     }
 
     // create required header fields that are not already written
@@ -1080,16 +1067,22 @@
         fprintf(f_output, "Cc: %s\n", item->email->cc_address);
     }
 
-    if (!has_bcc && item->email->bcc_address) {
-        fprintf(f_output, "Bcc: %s\n", item->email->bcc_address);
-    }
-
     if (!has_date && item->email->sent_date) {
         char c_time[C_TIME_SIZE];
         strftime(c_time, C_TIME_SIZE, "%a, %d %b %Y %H:%M:%S %z", gmtime(&em_time));
         fprintf(f_output, "Date: %s\n", c_time);
     }
 
+    // add forensic headers to capture some .pst stuff that is not really
+    // needed or used by mail clients
+    if (item->email->sender_address && !strchr(item->email->sender_address, '@')) {
+        fprintf(f_output, "X-libpst-forensic-sender: %s\n", item->email->sender_address);
+    }
+
+    if (item->email->bcc_address) {
+        fprintf(f_output, "X-libpst-forensic-bcc: %s\n", item->email->bcc_address);
+    }
+
     // add our own mime headers
     fprintf(f_output, "MIME-Version: 1.0\n");
     if (item->attach || (item->email->rtf_compressed && save_rtf)