Socket
Socket
Sign inDemoInstall

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 1.1.1 to 1.1.2

4

CHANGELOG.md

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

## [1.1.2] - 2021-01-07
- Add in-source JSDoc documentation.
## [1.1.1] - 2020-12-30

@@ -14,0 +18,0 @@

@@ -0,1 +1,16 @@

/**
* A simple shell escape package. Use it to escape user-controlled inputs to
* shell commands to prevent shell injection.
*
* @example
* const cp = require("child_process");
* const shescape = require("shescape");
* cp.spawn("command", shescape.escapeAll(userInput), options);
*
* @module shescape
* @version 1.1.2
* @license MPL-2.0
* @author Eric Cornelissen <ericornelissen@gmail.com>
*/
const os = require("os");

@@ -5,2 +20,12 @@

/**
* Take a single value, the argument, and escape any dangerous characters.
*
* Non-string inputs will be converted to strings using a `toString()` method.
*
* @param {string} arg The argument to escape.
* @returns {string} The escaped argument.
* @throws {TypeError} The argument is not stringable.
* @since 0.1.0
*/
module.exports.escape = function (arg) {

@@ -11,2 +36,14 @@ const platform = os.platform();

/**
* Take a array of values, the arguments, and escape any dangerous characters in
* every argument.
*
* Non-array inputs will be converted to one-value arrays and non-string values
* will be converted to strings using a `toString()` method.
*
* @param {string[]} args The arguments to escape.
* @returns {string[]} The escaped arguments.
* @throws {TypeError} One of the arguments is not stringable.
* @since 1.1.0
*/
module.exports.escapeAll = function (args) {

@@ -25,2 +62,13 @@ if (!Array.isArray(args)) args = [args];

/**
* Take a single value, the argument, put OS-specific quotes around it and
* escape any dangerous characters.
*
* Non-string inputs will be converted to strings using a `toString()` method.
*
* @param {string} arg The argument to quote and escape.
* @returns {string} The quoted and escaped argument.
* @throws {TypeError} The argument is not stringable.
* @since 0.3.0
*/
module.exports.quote = function (arg) {

@@ -31,2 +79,14 @@ const platform = os.platform();

/**
* Take an array of values, the arguments, put OS-specific quotes around every
* argument and escape any dangerous characters in every argument.
*
* Non-array inputs will be converted to one-value arrays and non-string values
* will be converted to strings using a `toString()` method.
*
* @param {string[]} args The arguments to quote and escape.
* @returns {string[]} The quoted and escaped arguments.
* @throws {TypeError} One of the arguments is not stringable.
* @since 0.4.0
*/
module.exports.quoteAll = function (args) {

@@ -33,0 +93,0 @@ if (!Array.isArray(args)) args = [args];

2

package.json
{
"name": "shescape",
"version": "1.1.1",
"version": "1.1.2",
"description": "simple shell escape library",

@@ -5,0 +5,0 @@ "homepage": "https://ericcornelissen.github.io/shescape/",

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