Using addcslashes on string to escape backtick

90 Views Asked by At

If i have the following string, i try to escape the backticks before passing to node vm.script(...) for execution

// test has been previously declared
$someStr = "test = `more/${test}`";
$escapedSomeStr = sprintf('%s', addcslashes($someStr, "`"));

I end up with double backslashes before the backticks like so if i output $escapedSomeStr i get the following

test = \\`more/${test}\\`

Some reading i've been doing indicates that PHP used to have magic quotes which adds the extra slash, but it doesnt appear to be turned on.

0

There are 0 best solutions below