Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

shescape

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shescape - npm Package Compare versions

Comparing version 0.2.1 to 0.3.0

5

CHANGELOG.md

@@ -12,2 +12,7 @@ # Changelog

## [0.3.0] - 2020-12-07
- Add `escape` function to escape an argument (same as `shescape()`).
- Add `quote` function to quote and escape an argument.
## [0.2.1] - 2020-11-07

@@ -14,0 +19,0 @@

@@ -9,1 +9,11 @@ const os = require("os");

};
module.exports.escape = function (arg) {
const platform = os.platform();
return main.escapeShellArgByPlatform(arg, platform);
};
module.exports.quote = function (arg) {
const platform = os.platform();
return main.quoteByPlatform(arg, platform);
};

9

package.json
{
"name": "shescape",
"version": "0.2.1",
"version": "0.3.0",
"description": "simple shell escape library",

@@ -11,2 +11,5 @@ "homepage": "https://github.com/ericcornelissen/shescape#readme",

"lint": "prettier --check ./**/*.{js,md,yml}",
"_postinstall": "is-ci || husky install",
"prepublishOnly": "pinst --disable",
"postpublish": "pinst --enable",
"test": "mocha"

@@ -32,4 +35,6 @@ },

"devDependencies": {
"husky": "^4.3.0",
"husky": "^5.0.4",
"is-ci": "^2.0.0",
"mocha": "^8.2.0",
"pinst": "^2.1.1",
"prettier": "^2.1.2",

@@ -36,0 +41,0 @@ "sinon": "^9.2.1"

@@ -11,4 +11,5 @@ # Shescape

Below is an example of how to use _Shescape_. Note that you must call _Shescape_
only on the user input, and put the output in between single quotes.
Below is a basic example of how to use _Shescape_. It is recommended to use the
`quote` function. This will put (OS appropriate) quotes around the user input
and escape any characters in the input if necessary.

@@ -19,3 +20,3 @@ ```js

cp.exec(`command '${shescape(userInput)}'`, callback);
cp.exec(`command ${shescape.quote(userInput)}`, callback);
```

@@ -22,0 +23,0 @@

@@ -14,2 +14,13 @@ const { win32 } = require("./constants.js");

function quoteByPlatform(arg, platform) {
const safeArg = escapeShellArgByPlatform(arg, platform);
switch (platform) {
case win32:
return `"${safeArg}"`;
default:
return `'${safeArg}'`;
}
}
module.exports.escapeShellArgByPlatform = escapeShellArgByPlatform;
module.exports.quoteByPlatform = quoteByPlatform;
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc