diff options
| author | Sukhbir Singh <sukhbir@torproject.org> | 2015-12-10 22:00:00 -0500 |
|---|---|---|
| committer | Sukhbir Singh <sukhbir@torproject.org> | 2015-12-10 22:00:00 -0500 |
| commit | bfa822de6071e894dad3d5c59e4fdf2ebacd91e2 (patch) | |
| tree | 5b0fadcc9f143431dc8af71f659dd0fa0eb60767 | |
| parent | 19cc1c71b9ee44554f3ff5ac6006da1380bd3a95 (diff) | |
| parent | 7169642643b91f203782d8e6a885d53fbb43f49e (diff) | |
Merge pull request #26 from arthuredelstein/6314
Bug #6314: Round Date header down to nearest minute.
| -rw-r--r-- | components/torbirdy.js | 20 |
1 files changed, 20 insertions, 0 deletions
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"); } |
