Skip to content

Commit

Permalink
refuse to escape strings with null bytes (#425)
Browse files Browse the repository at this point in the history
PHP also refuse to escape strings with null bytes, using a similar message. (not to mention, it's *literally impossible* to escape null bytes)
  • Loading branch information
divinity76 authored Oct 2, 2020
1 parent ea93f5b commit 406a4bc
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/php/exec/escapeshellarg.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ module.exports = function escapeshellarg (arg) {
// example 2: escapeshellarg("/home'; whoami;''")
// returns 2: "'/home'\''; whoami;'\'''\'''"

if(arg.indexOf("\x00") !== -1) {
throw new Error('escapeshellarg(): Argument #1 ($arg) must not contain any null bytes');
}

var ret = ''

ret = arg.replace(/\'/g, '\'\\\'\'')
Expand Down

0 comments on commit 406a4bc

Please sign in to comment.