diff --git a/api/src/Storage/History.php b/api/src/Storage/History.php index 5e2da548c4..ce1cebd041 100644 --- a/api/src/Storage/History.php +++ b/api/src/Storage/History.php @@ -32,6 +32,13 @@ class History */ var $db; const TABLE = 'egw_history_log'; + + /** + * PGP begin / end flags so we can handle them specially + */ + const BEGIN_PGP = '-----BEGIN PGP MESSAGE-----'; + const END_PGP = '-----END PGP MESSAGE-----'; + /** * App.name this class is instanciated for / working on * @@ -330,8 +337,24 @@ class History return $total; } - protected static function needs_diff($name, $value) + /** + * Check to see if we would rather store a unified diff of the changes rather + * than full old and new values. We don't care for small text values, but + * any long or multi-line values will be diff-ed. + * + * We do not store a diff of encrypted values, since that winds up as nonsense. + * + * @param string $name Field name, used to do some decision making + * @param string $value Value, either old or new + * @return boolean + */ + public static function needs_diff($name, $value) { + // No diff on encrypted content + if(strpos($value, static::BEGIN_PGP) == 0 && strpos($value, static::END_PGP) !== FALSE) + { + return false; + } return $name == 'note' || // Addressbook strpos($name, 'description') !== false || // Calendar, Records, Timesheet, ProjectManager, Resources $name == 'De' || // Tracker, InfoLog diff --git a/api/src/Storage/Tracking.php b/api/src/Storage/Tracking.php index 65afea6ed4..c3df6b9625 100644 --- a/api/src/Storage/Tracking.php +++ b/api/src/Storage/Tracking.php @@ -460,7 +460,7 @@ abstract class Tracking } } else if (is_string($data[$name]) && is_string($old[$name]) && ( - strpos($data[$name], PHP_EOL) !== FALSE || strpos($old[$name], PHP_EOL) !== FALSE)) + $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]))); @@ -931,7 +931,7 @@ abstract class Tracking protected function get_reply_to($data,$old) { $reply_to = $this->get_config('reply_to',$data,$old); - + return $reply_to; }