From be2f138cf0f1e6dc90763ff0e3caee55292f8c88 Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Wed, 24 Jun 2015 14:07:55 -0500
Subject: [PATCH] oops: Fix corrupted HTML if leading whitespace

This fixes an issue where text scrubbed with the new balancing system would
receive a leading ' <div>' if the text started with a leading whitespace.
---
 include/class.format.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/class.format.php b/include/class.format.php
index 407c9916b..be314d467 100644
--- a/include/class.format.php
+++ b/include/class.format.php
@@ -164,7 +164,7 @@ class Format {
             $html = $doc->saveHTML();
             $html = preg_replace('`^<!DOCTYPE.+?>|<\?xml .+?>|</?html>|</?body>|</?head>|<meta .+?/?>`', '', $html); # <?php
         }
-        return preg_replace('`^<div>|</div>$`', '', $html);
+        return preg_replace('`^<div>|</div>$`', '', trim($html));
     }
 
     function html($html, $config=array()) {
-- 
GitLab