From c1bc8f6c827a27540b5510b42dcc65b39d38f2c1 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Mon, 14 Oct 2013 07:19:37 -0400
Subject: [PATCH] Change so abort=true does not break the loop in exec_hook(), provide a new 'break' flag for this purpose

---
 program/lib/Roundcube/rcube_html2text.php |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/program/lib/Roundcube/rcube_html2text.php b/program/lib/Roundcube/rcube_html2text.php
index 3d32fe7..6f79e2f 100644
--- a/program/lib/Roundcube/rcube_html2text.php
+++ b/program/lib/Roundcube/rcube_html2text.php
@@ -597,18 +597,27 @@
                     // get blockquote content
                     $body = trim(substr($text, $startpos, $end - $startpos));
 
+                    // adjust text wrapping width
+                    $p_width = $this->width;
+                    if ($this->width > 0) $this->width -= 2;
+
                     // replace content with inner blockquotes
                     $this->_converter($body);
+
+                    // resore text width
+                    $this->width = $p_width;
 
                     // Add citation markers and create <pre> block
                     $body = preg_replace_callback('/((?:^|\n)>*)([^\n]*)/', array($this, 'blockquote_citation_ballback'), trim($body));
                     $body = '<pre>' . htmlspecialchars($body) . '</pre>';
 
-                    $text = substr($text, 0, $start) . $body . "\n" . substr($text, $end + 13);
+                    $text = substr_replace($text, $body . "\n", $start, $end + 13 - $start);
                     $offset = 0;
+
                     break;
                 }
-            } while ($end || $next);
+            }
+            while ($end || $next);
         }
     }
 
@@ -617,8 +626,9 @@
      */
     public function blockquote_citation_ballback($m)
     {
-        $line = ltrim($m[2]);
+        $line  = ltrim($m[2]);
         $space = $line[0] == '>' ? '' : ' ';
+
         return $m[1] . '>' . $space . $line;
     }
 

--
Gitblit v1.9.1