diff --git a/CHANGELOG b/CHANGELOG index 4b7bc1595..7af2da942 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,12 @@ CHANGELOG RoundCube Webmail --------------------------- +2006/12/03 (estadtherr) +---------- +- Added fix to convert HTML signatures for plain text messages +- Fixed signature delimeter character to be standard (Bug #1484035) + + 2006/12/01 (thomasb) ---------- - Implemented preview pane diff --git a/program/js/app.js b/program/js/app.js index 3d4d848dc..497598016 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -1714,50 +1714,54 @@ function rcube_webmail() if (this.env.identity && this.env.signatures && this.env.signatures[this.env.identity]) { sig = this.env.signatures[this.env.identity]['text']; - if (sig.indexOf('--')!=0) - sig = '--\n'+sig; - + if (sig.indexOf('-- ')!=0) + sig = '-- \n'+sig; + p = message.lastIndexOf(sig); if (p>=0) message = message.substring(0, p-1) + message.substring(p+sig.length, message.length); } - + // add the new signature string if (this.env.signatures && this.env.signatures[id]) { sig = this.env.signatures[id]['text']; - if (sig.indexOf('--')!=0) - sig = '--\n'+sig; + if (this.env.signatures[id]['is_html']) + { + sig = this.env.signatures[id]['plain_text']; + } + if (sig.indexOf('-- ')!=0) + sig = '-- \n'+sig; message += '\n'+sig; } } else { - var eid = tinyMCE.getEditorId('_message'); - // editor is a TinyMCE_Control object - var editor = tinyMCE.getInstanceById(eid); - var msgDoc = editor.getDoc(); - var msgBody = msgDoc.body; + var eid = tinyMCE.getEditorId('_message'); + // editor is a TinyMCE_Control object + var editor = tinyMCE.getInstanceById(eid); + var msgDoc = editor.getDoc(); + var msgBody = msgDoc.body; - if (this.env.signatures && this.env.signatures[id]) + if (this.env.signatures && this.env.signatures[id]) + { + // Append the signature as a span within the body + var sigElem = msgDoc.getElementById("_rc_sig"); + if (!sigElem) { - // Append the signature as a span within the body - var sigElem = msgDoc.getElementById("_rc_sig"); - if (!sigElem) - { - sigElem = msgDoc.createElement("span"); - sigElem.setAttribute("id", "_rc_sig"); - msgBody.appendChild(sigElem); - } - if (this.env.signatures[id]['is_html']) - { - sigElem.innerHTML = this.env.signatures[id]['text']; - } - else - { - sigElem.innerHTML = '
' + this.env.signatures[id]['text'] + ''; - } + sigElem = msgDoc.createElement("span"); + sigElem.setAttribute("id", "_rc_sig"); + msgBody.appendChild(sigElem); } + if (this.env.signatures[id]['is_html']) + { + sigElem.innerHTML = this.env.signatures[id]['text']; + } + else + { + sigElem.innerHTML = '
' + this.env.signatures[id]['text'] + ''; + } + } } if (input_message) diff --git a/program/lib/html2text.inc b/program/lib/html2text.inc index 36849a492..eabe15c69 100644 --- a/program/lib/html2text.inc +++ b/program/lib/html2text.inc @@ -164,7 +164,7 @@ class html2text '$this->_build_link_list("\\1", "\\2")', // "strtoupper(\"\n\n\\1\n\n\")", // H1 - H3 "ucwords(\"\n\n\\1\n\n\")", // H4 - H6 - "\n\n\t", //
+ "\n", //
"\n", //
'strtoupper("\\1")', //
'_\\1_', //
@@ -232,6 +232,15 @@ class html2text
* @see _build_link_list()
*/
var $_link_list = array();
+
+ /**
+ * Boolean flag, true if a table of link URLs should be listed after the text.
+ *
+ * @var boolean $_do_links
+ * @access private
+ * @see html2text()
+ */
+ var $_do_links = true;
/**
* Constructor.
@@ -242,15 +251,17 @@ class html2text
*
* @param string $source HTML content
* @param boolean $from_file Indicates $source is a file to pull content from
+ * @param boolean $do_link_table indicate whether a table of link URLs is desired
* @access public
* @return void
*/
- function html2text( $source = '', $from_file = false )
+ function html2text( $source = '', $from_file = false, $do_link_table = true )
{
if ( !empty($source) ) {
$this->set_html($source, $from_file);
}
$this->set_base_url();
+ $this->_do_links = $produce_link_table;
}
/**
@@ -409,6 +420,8 @@ class html2text
*/
function _build_link_list($link, $display)
{
+ if (! $this->_do_links) return $display;
+
$link_lc = strtolower($link);
if (substr($link_lc, 0, 7) == 'http://' || substr($link_lc, 0, 8) == 'https://' || substr($link_lc, 0, 7) == 'mailto:')
diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc
index 76aa78f4b..6e1126b86 100644
--- a/program/steps/mail/compose.inc
+++ b/program/steps/mail/compose.inc
@@ -20,6 +20,7 @@
*/
require_once('Mail/mimeDecode.php');
+require_once('lib/html2text.inc');
// define constants for message compose mode
define('RCUBE_COMPOSE_REPLY', 0x0106);
@@ -296,6 +297,12 @@ function rcmail_compose_header_from($attrib)
{
$a_signatures[$identity_id]['text'] = $sql_arr['signature'];
$a_signatures[$identity_id]['is_html'] = ($sql_arr['html_signature'] == 1) ? true : false;
+ if ($a_signatures[$identity_id]['is_html'])
+ {
+ $h2t = new html2text($a_signatures[$identity_id]['text'], false, false);
+ $plainTextPart = $h2t->get_text();
+ $a_signatures[$identity_id]['plain_text'] = trim($plainTextPart);
+ }
}
// set identity if it's one of the reply-message recipients
diff --git a/program/steps/settings/edit_identity.inc b/program/steps/settings/edit_identity.inc
index a7303bdf0..1ea8947b7 100644
--- a/program/steps/settings/edit_identity.inc
+++ b/program/steps/settings/edit_identity.inc
@@ -56,7 +56,7 @@ function rcube_identity_form($attrib)
"theme_advanced_toolbar_location : 'top'," .
"theme_advanced_toolbar_align : 'left'," .
"theme_advanced_buttons1 : 'bold,italic,underline,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,separator,outdent,indent,charmap,hr'," .
- "theme_advanced_buttons2 : 'link,unlink,forecolor,fontselect,fontsizeselect'," .
+ "theme_advanced_buttons2 : 'link,unlink,code,forecolor,fontselect,fontsizeselect'," .
"theme_advanced_buttons3 : '' });");
if (!$IDENTITY_RECORD && $GLOBALS['_action']!='add-identity')