npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

php-escape-shell

v1.0.0

Published

Based on php shell metacharacters escape functions

Downloads

356

Readme

node-php-escape-shell

Based on php shell metacharacters escape functions

Install

npm install php-escape-shell

Description

escapeshellarg

php_escapeshellarg() adds single quotes around a string and quotes/escapes any existing single quotes allowing you to pass a string directly to a shell function and having it be treated as a single safe argument.
This function should be used to escape individual arguments to shell functions coming from user input.
On Windows, php_escapeshellarg() instead removes percent signs, replaces double quotes with spaces and adds double quotes around the string.

php_escapeshellarg(cmd)

escapeshellarg() adds more options to the php original escapeshellarg function, isWindows - added to allow escaping linux style args in windows os and vice versa. escapeWinEnv - added to disable escaping of windows environment variables like %windir%.

escapeshellarg(cmd[, isWindows[, escapeWinEnv]])

escapeshellcmd

php_escapeshellcmd() escapes any characters in a string that might be used to trick a shell command into executing arbitrary commands. This function should be used to make sure that any data coming from user input is escaped before this data is passed to the exec() functions. Following characters are preceded by a backslash: #&;`|*?~<>^()[]{}$, \x0A and \xFF. ' and " are escaped only if they are not paired. In Windows, all these characters plus % are replaced by a space instead.

php_escapeshellcmd(cmd)

escapeshellcmd() adds more options to the php original escapeshellcmd function,
isWindows - added to allow escaping linux style args in windows os and vice versa. escapeWinEnv - added to disable escaping of windows environment variables like %windir%.

escapeshellcmd(cmd[, isWindows[, escapeWinEnv]])

Example

escapeshellarg

var php_escapeshellarg = require('php-escape-shell').php_escapeshellarg;

var dir = "src\" && nc -lvvp 4444 && echo \"";
console.log("cmd.exe /C dir " + php_escapeshellarg(dir));

Output (In Windows): cmd.exe /C dir "src && nc -lvvp 4444 && echo "

var escapeshellarg = require('php-escape-shell').escapeshellarg;

var dir = "%WINDIR%";
console.log("cmd.exe /C dir " + escapeshellarg(dir, true, false));

Output: cmd.exe /C dir "%WINDIR%"

escapeshellcmd

var php_escapeshellcmd = require('php-escape-shell').php_escapeshellcmd;

var dir = "src\" && nc -lvvp 4444 && echo \"";
console.log(php_escapeshellcmd("cmd.exe /C dir " + dir));

Output (In Windows): cmd.exe /C dir src^" ^&^& nc -lvvp 4444 ^&^& echo ^"

var escapeshellcmd = require('php-escape-shell').escapeshellcmd;

var dir = "%WINDIR%";
console.log(escapeshellcmd("cmd.exe /C dir " + dir, true, false));

Output: cmd.exe /C dir %WINDIR%

License

MIT