Itay Moav -Malimovka
Itay Moav -Malimovka

Reputation: 53607

How do I reverse escapeshellarg?

Well, header says it all.
in php, how do I reverse escapeshellarg()? To be more precise, what is the built-in function (if there is one) that will reverse it.

Upvotes: 3

Views: 1104

Answers (2)

gggeek
gggeek

Reputation: 331

Usecase:
When creating a command, all args have to be properly escaped. But when using PS to find if that command is executing, the quotes are stripped. So a comparison is difficult. In the case where the only programs to check are the ones started by php saving the PID is ok, but if we have to take into account processes which have been started from other means, it is more difficult

Upvotes: 0

WWW
WWW

Reputation: 9860

Most thorough route would be to find out exactly what escapeshellarg() does and do the opposite. In a linux environment, it looks like it's just taking care of single quotes. In a Windows environment, it's doing a bit more. Your reverse function should take that into account as well.

Regarding a built-in function: The short answer is "there isn't one." The long answer is: there isn't one because escaped shell arguments aren't ever intended to get parsed by PHP (why escape them in the first place?) so nobody ever wrote one and submitted it as a patch to PHP. If you're passing arguments into a CLI PHP application, you don't need to unescape things as that was done already by the interpreter.

Upvotes: 5

Related Questions