Skip to content

Commit b047f52

Browse files
committed
better sanitization
1 parent de93140 commit b047f52

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

psCommandService.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,9 @@ PSCommandService.prototype._finalizeParameterValue = function(valueToSet, applyQ
355355
}
356356

357357
PSCommandService.prototype._sanitize = function(toSanitize,isQuoted) {
358-
toSanitize.replace(/(\n)/g, "\\$1"); // escape newlines
358+
toSanitize = toSanitize.replace(/([\n\r])/g, ""); // kill true newlines/feeds
359+
360+
toSanitize = toSanitize.replace(/(\\n)/g, "\\$1"); // kill string based newline attempts
359361

360362
// escape stuff that could screw up variables
361363
toSanitize = toSanitize.replace(/([`#])/g, "`$1");
@@ -366,7 +368,7 @@ PSCommandService.prototype._sanitize = function(toSanitize,isQuoted) {
366368

367369
// if not quoted, stop $ and |
368370
} else {
369-
toSanitize = toSanitize.replace(/([\$\|])/g, "`$1");
371+
toSanitize = toSanitize.replace(/([\$\|\(\)\{\}\[\]]\\)/g, "`$1");
370372
}
371373

372374
return toSanitize;

0 commit comments

Comments
 (0)