Permalink
Browse files

Take into account Reply-To headers that contain a list of addresses.

  • Loading branch information...
1 parent 5336720 commit 3503007388ed0656a08ddfa78c3fce58143c8d1b @protz committed May 6, 2012
Showing with 15 additions and 7 deletions.
  1. +8 −6 compose.js
  2. +7 −1 misc.js
View
@@ -358,7 +358,8 @@ function replyAllParams(aIdentity, aMsgHdr, k) {
let finish = function (to, cc, bcc) {
let hashMap = {};
- hashMap[to[0][1]] = null;
+ for each (let [name, email] in to)
+ hashMap[email] = null;
cc = cc.filter(function ([name, email])
let (r = (email in hashMap))
(hashMap[email] = null,
@@ -375,15 +376,16 @@ function replyAllParams(aIdentity, aMsgHdr, k) {
// Do we have a Reply-To header?
msgHdrGetHeaders(aMsgHdr, function (aHeaders) {
if (aHeaders.has("reply-to")) {
- let [[name], [email]] = parse(aHeaders.get("reply-to"));
- email = email.toLowerCase();
- if (email) {
+ let [names, emails] = parse(aHeaders.get("reply-to"));
+ emails = [email.toLowerCase() for each (email in emails)];
+ if (emails.length) {
+ // Invariant: at this stage, we only have one item in to.
cc = cc.concat([to[0]]); // move the to in cc
- to = [[name, email]];
+ to = combine(names, emails);
}
}
finish(to, cc, bcc);
- }); // do download
+ });
}
/**
View
@@ -45,7 +45,7 @@ var EXPORTED_SYMBOLS = [
// Identity management helpers
'gIdentities', 'fillIdentities',
// JS programming helpers
- 'range', 'MixIn',
+ 'range', 'MixIn', 'combine',
// XPCOM helpers
'NS_FAILED', 'NS_SUCCEEDED',
// Various formatting helpers
@@ -273,3 +273,9 @@ function systemCharset() {
}
return charset;
}
+
+function combine(a1, a2) {
+ if (a1.length != a2.length)
+ throw new Error("combine: the given arrays have different lengths");
+ return [[a1[i], a2[i]] for each (i in range(0, a1.length))];
+}

0 comments on commit 3503007

Please sign in to comment.