user4262239
user4262239

Reputation:

Can't pass a variable from php to exec

I have some PHP code which gets the contents from "php://input".

if (!isset($HTTP_RAW_POST_DATA)) {
$HTTP_RAW_POST_DATA = file_get_contents("php://input"); 

Now, I'm trying to remove the XML tags from $HTTP_RAW_POST_DATA using sed, like this:

exec("/usr/bin/sed -e 's/\<3\>//g' -e 's/\<\/3\>//g' $HTTP_RAW_POST_DATA");

Then, I try echoing $HTTP_RAW_POST_DATA like this:

echo("$HTTP_RAW_POST_DATA");

But it still returns it with <3> and </3>. Seems like sed can't read the variable.

What can I do to fix this? I get no error messages.

Upvotes: 1

Views: 43

Answers (1)

motanelu
motanelu

Reputation: 4025

Just use strip_tags() - http://php.net/manual/en/function.strip-tags.php - does exactly what you want sed to do without the horrible security implications.

Upvotes: 1

Related Questions