Escaping cwd, fix #7

This commit is contained in:
WebFreak001 2016-02-05 15:32:08 +01:00
commit 3831f07c2a

View file

@ -16,7 +16,7 @@ export class MI2 extends EventEmitter implements IBackend {
this.process.on("exit", (() => { this.emit("quit"); }).bind(this)); this.process.on("exit", (() => { this.emit("quit"); }).bind(this));
Promise.all([ Promise.all([
this.sendCommand("gdb-set target-async on"), this.sendCommand("gdb-set target-async on"),
this.sendCommand("environment-directory \"" + cwd + "\"") this.sendCommand("environment-directory \"" + cwd.replace(/\\/g, "\\\\").replace(/"/g, "\\\"") + "\"")
]).then(resolve, reject); ]).then(resolve, reject);
}); });
} }
@ -33,7 +33,7 @@ export class MI2 extends EventEmitter implements IBackend {
this.process.on("exit", (() => { this.emit("quit"); }).bind(this)); this.process.on("exit", (() => { this.emit("quit"); }).bind(this));
Promise.all([ Promise.all([
this.sendCommand("gdb-set target-async on"), this.sendCommand("gdb-set target-async on"),
this.sendCommand("environment-directory \"" + cwd + "\"") this.sendCommand("environment-directory \"" + cwd.replace(/\\/g, "\\\\").replace(/"/g, "\\\"") + "\"")
]).then(resolve, reject); ]).then(resolve, reject);
}); });
} }
@ -51,7 +51,7 @@ export class MI2 extends EventEmitter implements IBackend {
this.process.on("exit", (() => { this.emit("quit"); }).bind(this)); this.process.on("exit", (() => { this.emit("quit"); }).bind(this));
Promise.all([ Promise.all([
this.sendCommand("gdb-set target-async on"), this.sendCommand("gdb-set target-async on"),
this.sendCommand("environment-directory \"" + cwd + "\""), this.sendCommand("environment-directory \"" + cwd.replace(/\\/g, "\\\\").replace(/"/g, "\\\"") + "\""),
this.sendCommand("target-select remote " + target) this.sendCommand("target-select remote " + target)
]).then(resolve, reject); ]).then(resolve, reject);
}); });
@ -133,7 +133,7 @@ export class MI2 extends EventEmitter implements IBackend {
}); });
this.sendRaw("-gdb-exit"); this.sendRaw("-gdb-exit");
} }
detach() { detach() {
let proc = this.process; let proc = this.process;
let to = setTimeout(() => { let to = setTimeout(() => {