fix #910: removing bad characters from input

This commit is contained in:
antelle 2019-03-31 15:05:48 +02:00
parent 62e3068af1
commit 2820141897
1 changed files with 10 additions and 0 deletions

View File

@ -390,6 +390,7 @@ const EntryModel = Backbone.Model.extend({
const hasValue = val && (typeof val === 'string' || val.isProtected && val.byteLength);
if (hasValue || allowEmpty || this.builtInFields.indexOf(field) >= 0) {
this._entryModified();
val = this.sanitizeFieldValue(val);
this.entry.fields[field] = val;
} else if (this.entry.fields.hasOwnProperty(field)) {
this._entryModified();
@ -398,6 +399,15 @@ const EntryModel = Backbone.Model.extend({
this._fillByEntry();
},
sanitizeFieldValue: function(val) {
if (val && !val.isProtected && val.indexOf('\x1A') >= 0) {
// https://github.com/keeweb/keeweb/issues/910
// eslint-disable-next-line no-control-regex
val = val.replace(/\x1A/g, '');
}
return val;
},
hasField: function(field) {
return this.entry.fields.hasOwnProperty(field);
},