From 8edb92f03f7c1d8962ea0b2eae460621f46b4ccb Mon Sep 17 00:00:00 2001 From: nathangray Date: Thu, 6 Jun 2019 15:05:31 -0600 Subject: [PATCH] Strip HTML before diffing for history --- api/src/Storage/Tracking.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/api/src/Storage/Tracking.php b/api/src/Storage/Tracking.php index c3df6b9625..f07d9ec90e 100644 --- a/api/src/Storage/Tracking.php +++ b/api/src/Storage/Tracking.php @@ -463,7 +463,18 @@ abstract class Tracking $this->historylog->needs_diff ($name, $data[$name]) || $this->historylog->needs_diff ($name, $old[$name]))) { // Multiline string, just store diff - $diff = new \Horde_Text_Diff('auto', array(explode("\n",$old[$name]), explode("\n",$data[$name]))); + // Strip HTML first though + $old_text = Api\Mail\Html::convertHTMLToText($old[$name]); + $new_text = Api\Mail\Html::convertHTMLToText($data[$name]); + + // If only change was something in HTML, show the HTML + if(trim($old_text) === trim($new_text)) + { + $old_text = $old[$name]; + $new_text = $data[$name]; + } + + $diff = new \Horde_Text_Diff('auto', array(explode("\n",$old_text), explode("\n",$new_text))); $renderer = new \Horde_Text_Diff_Renderer_Unified(); $this->historylog->add( $status,