mirror of https://github.com/keeweb/keeweb.git
protected values comparison
This commit is contained in:
parent
0e1dcdb11b
commit
b583f249d7
|
@ -78,4 +78,26 @@ kdbxweb.ProtectedValue.prototype.includesLower = function(findLower) {
|
|||
return matches;
|
||||
};
|
||||
|
||||
kdbxweb.ProtectedValue.prototype.equals = function(other) {
|
||||
if (!other) {
|
||||
return false;
|
||||
}
|
||||
if (!other.isProtected) {
|
||||
return this.textLength === other.length && this.includes(other);
|
||||
}
|
||||
if (other === this) {
|
||||
return true;
|
||||
}
|
||||
var len = this.byteLength;
|
||||
if (len !== other.byteLength) {
|
||||
return false;
|
||||
}
|
||||
for (var i = 0; i < len; i++) {
|
||||
if ((this._value[i] ^ this._salt[i]) !== (other._value[i] ^ other._salt[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
module.exports = kdbxweb.ProtectedValue;
|
||||
|
|
|
@ -86,9 +86,14 @@ var FieldView = Backbone.View.extend({
|
|||
return;
|
||||
}
|
||||
this.editing = false;
|
||||
var oldValText = this.value && this.value.isProtected ? this.value.getText() : this.value;
|
||||
var newValText = newVal && newVal.isProtected ? newVal.getText() : newVal;
|
||||
var textEqual = _.isEqual(newValText, oldValText);
|
||||
var textEqual;
|
||||
if (this.value && this.value.isProtected) {
|
||||
textEqual = this.value.equals(newVal);
|
||||
} else if (newVal && newVal.isProtected) {
|
||||
textEqual = newVal.equals(this.value);
|
||||
} else {
|
||||
textEqual = _.isEqual(this.value, newVal);
|
||||
}
|
||||
var protectedEqual = (newVal && newVal.isProtected) === (this.value && this.value.isProtected);
|
||||
var nameChanged = extra && extra.newField;
|
||||
var arg;
|
||||
|
|
Loading…
Reference in New Issue