From 16426dd29a2d6256674a70fa7790cc5b87c0da50 Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Wed, 2 Oct 2013 01:57:42 +0000
Subject: [PATCH] Fix html2text output for empty headline elements

---
 include/html2text.php | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/include/html2text.php b/include/html2text.php
index 51137d002..944c62f19 100644
--- a/include/html2text.php
+++ b/include/html2text.php
@@ -346,8 +346,9 @@ class HtmlHrElement extends HtmlBlockElement {
 
 class HtmlHeadlineElement extends HtmlBlockElement {
     function render($width, $options) {
-        $headline = parent::render($width, $options) . "\n";
         $line = false;
+        if (!($headline = parent::render($width, $options)))
+            return "";
         switch ($this->node->nodeName) {
             case 'h1':
             case 'h2':
@@ -357,9 +358,10 @@ class HtmlHeadlineElement extends HtmlBlockElement {
             case 'h4':
                 $line = '-';
                 break;
+            default:
+                return $headline;
         }
-        if ($line)
-            $headline .= str_repeat($line, strpos($headline, "\n", 1) - 1) . "\n";
+        $headline .= "\n" . str_repeat($line, strpos($headline, "\n", 1) - 1) . "\n";
         return $headline;
     }
 }
-- 
GitLab