[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [torbirdy/develop] Bug #6314: Round Date header down to nearest minute.



commit 7169642643b91f203782d8e6a885d53fbb43f49e
Author: Arthur Edelstein <arthuredelstein@xxxxxxxxx>
Date:   Tue Dec 8 16:59:22 2015 -0800

    Bug #6314: Round Date header down to nearest minute.
---
 components/torbirdy.js | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/components/torbirdy.js b/components/torbirdy.js
index 5867f98..1dd87fe 100644
--- a/components/torbirdy.js
+++ b/components/torbirdy.js
@@ -312,6 +312,25 @@ var TorBirdyOldPrefs = [
   "network.proxy.http",
 ]
 
+// sanitizeDateHeaders()
+// Run this function to make sure that the Date header in a new message
+// is rounded down to the nearest minute.
+function sanitizeDateHeaders() {
+  // Import the jsmime module that is used to generate mail headers.
+  let { jsmime } = Components.utils.import("resource:///modules/jsmime.jsm");
+  // Inject our own structured encoder to the default header emitter,
+  // to override the default Date encoder with a rounded-down version.
+  jsmime.headeremitter.addStructuredEncoder("Date", function (date) {
+    // Copy date
+    let roundedDate = new Date(date.getTime());
+    // Round down to the nearest minute.
+    roundedDate.setSeconds(0);
+    // Use the headeremitter's addDate function to format it properly.
+    // `this` magically refers to the headeremitter object.
+    this.addDate(roundedDate);
+  });
+}
+
 function TorBirdy() {
   this._uninstall = false;
   this.wrappedJSObject = this;
@@ -339,6 +358,7 @@ function TorBirdy() {
 
   this.setAccountPrefs();
   this.setPrefs();
+  sanitizeDateHeaders();
 
   dump("TorBirdy registered!\n");
 }



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits