Do not store a diff for encrypted values, that is not useful.

This commit is contained in:
nathangray 2019-03-25 10:06:59 -06:00
parent 53bff47792
commit 0324c7d6e6
2 changed files with 26 additions and 3 deletions

View File

@ -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

View File

@ -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;
}