Socket
Socket
Sign inDemoInstall

cross-spawn

Package Overview
Dependencies
0
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.2 to 0.1.3

bar

29

index.js

@@ -6,19 +6,20 @@ var cp = require('child_process');

function escapeArg(arg, quote) {
// Sequence of backslashes followed by a double quote:
// double up all the backslashes and escape the double quote
arg = arg.replace(/(\\*)"/gi, '$1$1\\"');
// If we not going to quote the argument,
// escape shell metacharacters, including double and single quotes:
if (!quote) {
arg = arg.replace(/([\(\)%!\^<>&|;,"' ])/g, '^$1');
} else {
// Sequence of backslashes followed by a double quote:
// double up all the backslashes and escape the double quote
arg = arg.replace(/(\\*)"/gi, '$1$1\\"');
// Sequence of backslashes followed by the end of the string
// (which will become a double quote later):
// double up all the backslashes
arg = arg.replace(/(\\*)$/, '$1$1');
// Sequence of backslashes followed by the end of the string
// (which will become a double quote later):
// double up all the backslashes
arg = arg.replace(/(\\*)$/, '$1$1');
// All other backslashes occur literally
// All other backslashes occur literally
// Quote the whole thing:
if (quote) {
// Quote the whole thing:
arg = '"' + arg + '"';
// Or escape shell metacharacters:
} else {
arg = arg.replace(/([\(\)%!\^<>&|;, ])/g, '^$1');
}

@@ -45,3 +46,3 @@

// Escape command & arguments
applyQuotes = command !== 'echo';
applyQuotes = command !== 'echo'; // Do note quote arguments for the special "echo" command
command = escapeCommand(command);

@@ -48,0 +49,0 @@ args = (args || []).map(function (arg) {

{
"name": "cross-spawn",
"version": "0.1.2",
"version": "0.1.3",
"description": "Cross platform child_process#spawn",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -65,3 +65,3 @@ 'use strict';

it('should handle arguments with \\\\"', function (next) {
it('should handle arguments with \\"', function (next) {
buffered('node', [

@@ -122,6 +122,6 @@ __dirname + '/fixtures/echo',

it('should handle special arguments when using echo', function (next) {
buffered('echo', ['foo&bar'], function (err, data, code) {
buffered('echo', ['foo\\"foo\\foo&bar"foo\'bar'], function (err, data, code) {
expect(err).to.not.be.ok();
expect(code).to.be(0);
expect(data.trim()).to.equal('foo&bar');
expect(data.trim()).to.equal('foo\\"foo\\foo&bar"foo\'bar');

@@ -128,0 +128,0 @@ next();

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc