summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2012-08-15 09:05:44 +0200
committerAleksander Machniak <alec@alec.pl>2012-08-15 09:09:29 +0200
commit95cec992ebe4dcaab5daae20f11b2e37d577b2d7 (patch)
tree3d7c183810a4ad49b944aa1f3b89b684b0ceb9b8
parentef950cb7122aec54800e970597507c7db6440289 (diff)
Fix stripped apostrophes when replying in plain text to HTML message (#1488606)
-rw-r--r--CHANGELOG1
-rw-r--r--program/lib/html2text.php30
-rw-r--r--program/steps/mail/sendmail.inc15
3 files changed, 19 insertions, 27 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 1aa7456c1..2a1822f00 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
CHANGELOG Roundcube Webmail
===========================
+- Fix stripped apostrophes when replying in plain text to HTML message (#1488606)
- Fix inactive Save search option after advanced search (#1488607)
- Fix Remove from group option is active for contact search result (#1488608)
- Disable autocapitalization in login form on iPad/iPhone (#1488609)
diff --git a/program/lib/html2text.php b/program/lib/html2text.php
index 9de2e961e..28c5ae059 100644
--- a/program/lib/html2text.php
+++ b/program/lib/html2text.php
@@ -89,7 +89,7 @@
* out that extra spaces should be compressed--a problem addressed with
* Marcus Bointon's fixes but that I had not yet incorporated.
*
- * Thanks to Daniel Schledermann (http://www.typoconsult.dk/) for
+ * Thanks to Daniel Schledermann (http://www.typoconsult.dk/) for
* suggesting a valuable fix with <a> tag handling.
*
* Thanks to Wojciech Bajon (again!) for suggesting fixes and additions,
@@ -200,7 +200,7 @@ class html2text
var $ent_search = array(
'/&(nbsp|#160);/i', // Non-breaking space
'/&(quot|rdquo|ldquo|#8220|#8221|#147|#148);/i',
- // Double quotes
+ // Double quotes
'/&(apos|rsquo|lsquo|#8216|#8217);/i', // Single quotes
'/&gt;/i', // Greater-than
'/&lt;/i', // Less-than
@@ -437,11 +437,11 @@ class html2text
function set_base_url( $url = '' )
{
if ( empty($url) ) {
- if ( !empty($_SERVER['HTTP_HOST']) ) {
- $this->url = 'http://' . $_SERVER['HTTP_HOST'];
- } else {
- $this->url = '';
- }
+ if ( !empty($_SERVER['HTTP_HOST']) ) {
+ $this->url = 'http://' . $_SERVER['HTTP_HOST'];
+ } else {
+ $this->url = '';
+ }
} else {
// Strip any trailing slashes for consistency (relative
// URLs may already start with a slash like "/file.html")
@@ -515,7 +515,7 @@ class html2text
$text = preg_replace($this->ent_search, $this->ent_replace, $text);
// Replace known html entities
- $text = html_entity_decode($text, ENT_COMPAT, 'UTF-8');
+ $text = html_entity_decode($text, ENT_QUOTES, 'UTF-8');
// Remove unknown/unhandled entities (this cannot be done in search-and-replace block)
$text = preg_replace('/&([a-zA-Z0-9]{2,6}|#[0-9]{2,4});/', '', $text);
@@ -535,7 +535,7 @@ class html2text
// for PHP versions >= 4.0.2. Default width is 75
// If width is 0 or less, don't wrap the text.
if ( $this->width > 0 ) {
- $text = wordwrap($text, $this->width);
+ $text = wordwrap($text, $this->width);
}
}
@@ -554,16 +554,16 @@ class html2text
*/
function _build_link_list( $link, $display )
{
- if (!$this->_do_links || empty($link)) {
- return $display;
- }
+ if (!$this->_do_links || empty($link)) {
+ return $display;
+ }
// Ignored link types
- if (preg_match('!^(javascript:|mailto:|#)!i', $link)) {
- return $display;
+ if (preg_match('!^(javascript:|mailto:|#)!i', $link)) {
+ return $display;
}
- if (preg_match('!^([a-z][a-z0-9.+-]+:)!i', $link)) {
+ if (preg_match('!^([a-z][a-z0-9.+-]+:)!i', $link)) {
$url = $link;
}
else {
diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc
index faaeddcda..c4cfc6013 100644
--- a/program/steps/mail/sendmail.inc
+++ b/program/steps/mail/sendmail.inc
@@ -501,14 +501,9 @@ if ($isHtml) {
$h2t = new html2text($plugin['body'], false, true, 0);
$plainTextPart = rc_wordwrap($h2t->get_text(), $LINE_LENGTH, "\r\n");
$plainTextPart = wordwrap($plainTextPart, 998, "\r\n", true);
- if (!$plainTextPart) {
- // empty message body breaks attachment handling in drafts
- $plainTextPart = "\r\n";
- }
- else {
- // make sure all line endings are CRLF (#1486712)
- $plainTextPart = preg_replace('/\r?\n/', "\r\n", $plainTextPart);
- }
+
+ // make sure all line endings are CRLF (#1486712)
+ $plainTextPart = preg_replace('/\r?\n/', "\r\n", $plainTextPart);
$plugin = $RCMAIL->plugins->exec_hook('message_outgoing_body',
array('body' => $plainTextPart, 'type' => 'alternative', 'message' => $MAIL_MIME));
@@ -532,10 +527,6 @@ else {
$message_body = rc_wordwrap($message_body, $LINE_LENGTH, "\r\n");
$message_body = wordwrap($message_body, 998, "\r\n", true);
- if (!strlen($message_body)) {
- // empty message body breaks attachment handling in drafts
- $message_body = "\r\n";
- }
$MAIL_MIME->setTXTBody($message_body, false, true);
}