escape chars

This commit is contained in:
antelle 2016-04-23 19:31:39 +03:00
parent 31c6c10381
commit a3afc4f7e4
2 changed files with 22 additions and 3 deletions

View File

@ -186,11 +186,30 @@ AutoTypeRunner.prototype.getEntryFieldKeys = function(field, op) {
op.type = 'group';
var ops = [];
value.forEachChar(function(ch) {
ops.push({ type: 'text', value: String.fromCharCode(ch) });
if (ch === 10 || ch === 13) {
ops.push({type: 'key', value: 'enter'});
} else {
ops.push({type: 'text', value: String.fromCharCode(ch)});
}
});
return ops.length ? ops : '';
} else {
var parts = value.split(/[\r\n]/g);
if (parts.length === 1) {
return value;
}
op.type = 'group';
var partsOps = [];
parts.forEach(function(part) {
if (partsOps.length) {
partsOps.push({type: 'key', value: 'enter'});
}
if (part) {
partsOps.push({type: 'text', value: part});
}
});
return partsOps;
}
return value;
};
AutoTypeRunner.prototype.getEntryGroupName = function() {

View File

@ -37,7 +37,7 @@ AutoTypeEmitter.prototype.setMod = function(mod, enabled) {
};
AutoTypeEmitter.prototype.text = function(text) {
text = text.replace(/"/g, '\\"');
text = text.replace(/"/g, '\\"').replace(/\\/g, '\\\\');
this.pendingScript.push('keystroke "' + text + '"'+ this.modString());
this.callback();
};