From 8deae975f0589fccb171b16d54c4b6d9eb569a1b Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Sun, 15 Sep 2013 10:48:44 -0400
Subject: [PATCH] Fixed issues in handling reply-to/bcc fields on identity change
---
program/js/app.js | 21 ++++++++++++---------
1 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/program/js/app.js b/program/js/app.js
index 24aaca0..337a121 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -3427,7 +3427,8 @@
message = input_message.val(),
is_html = ($("input[name='_is_html']").val() == '1'),
sig = this.env.identity,
- delim = this.env.recipients_delimiter,
+ delim = this.env.recipients_separator,
+ rx_delim = RegExp.escape(delim),
headers = ['replyto', 'bcc'];
// update reply-to/bcc fields with addresses defined in identities
@@ -3444,16 +3445,18 @@
}
// cleanup
- rx = new RegExp(RegExp.escape(delim) + '\\s*' + RegExp(delim), 'g');
- input_val = input_val.replace(rx, delim)
- rx = new RegExp('^\\s*' + RegExp.escape(delim) + '\\s*$');
- input_val = input_val.replace(rx, '')
+ rx = new RegExp(rx_delim + '\\s*' + rx_delim, 'g');
+ input_val = input_val.replace(rx, delim);
+ rx = new RegExp('^[\\s' + rx_delim + ']+');
+ input_val = input_val.replace(rx, '');
// add new address(es)
- if (new_val) {
- rx = new RegExp(RegExp.escape(delim) + '\\s*$');
- if (input_val && !rx.test(input_val))
- input_val += delim + ' ';
+ if (new_val && input_val.indexOf(new_val) == -1 && input_val.indexOf(new_val.replace(/"/g, '')) == -1) {
+ if (input_val) {
+ rx = new RegExp('[' + rx_delim + '\\s]+$')
+ input_val = input_val.replace(rx, '') + delim + ' ';
+ }
+
input_val += new_val + delim + ' ';
}
--
Gitblit v1.9.1