Skip to content

Commit 4a25ac4

Browse files
committed
fix quoting flag for escaping
1 parent 568727f commit 4a25ac4

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

psCommandService.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ PSCommandService.prototype.execute = function(commandName, argument2ValueMap) {
123123
cmdResult['commandName'] = commandName;
124124
fulfill(cmdResult);
125125
}).catch(function(error){
126-
reject(error);
126+
reject(error);
127127
});
128128
});
129129
}
@@ -311,7 +311,7 @@ PSCommandService.prototype._generateCommand = function(commandConfig, argument2V
311311
if (valueToSet && valueToSet.trim().length > 0) {
312312

313313
// sanitize
314-
valueToSet = this._sanitize(valueToSet);
314+
valueToSet = this._sanitize(valueToSet,isQuoted);
315315

316316
// append w/ quotes (SINGLE QUOTES, not double to avoid expansion)
317317
argumentValues += (this._finalizeParameterValue(valueToSet,isQuoted) + ",");
@@ -354,12 +354,16 @@ PSCommandService.prototype._finalizeParameterValue = function(valueToSet, applyQ
354354
return valueToSet;
355355
}
356356

357-
PSCommandService.prototype._sanitize = function(toSanitize) {
357+
PSCommandService.prototype._sanitize = function(toSanitize,isQuoted) {
358358
toSanitize.replace(/(\n)/g, "\\$1"); // escape newlines
359359

360360
// escape stuff that could screw up variables
361361
toSanitize = toSanitize.replace(/([`#])/g, "`$1");
362362

363363
// fix quote breaking
364-
return toSanitize.replace(/(['])/g, "'$1")
364+
if (isQuoted) {
365+
toSanitize = toSanitize.replace(/(['])/g, "'$1");
366+
}
367+
368+
return toSanitize;
365369
}

0 commit comments

Comments
 (0)