Skip to content

Commit 6bc0f72

Browse files
committed
fixed argument parsing
1 parent 0912d16 commit 6bc0f72

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

connection.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,14 @@ module.exports = function (socket, cmdHandler) {
6666
function executeCommandBuffer(buffer, listOk) {
6767
// execute all commands in the command buffer in the order and waiting for their response
6868
return buffer.reduce((p, command, i) => p.then(() => {
69-
let args = command.match(/\w+|"(?:\\"|[^"])+/g);
69+
let reg = /"([^"]*)"|[^\s]+/g;
70+
let args = [];
71+
let match;
72+
73+
while (match = reg.exec(command)) {
74+
args.push(match[1] || match[0]);
75+
}
76+
7077
return executeCommand(args[0], args.slice(1)).then((resp) => {
7178
// write the command response
7279
socket.write(resp);

0 commit comments

Comments
 (0)