Alternate way would be to remove it from everywhere and just do
foreach ($_POST as $key => $value){
$_POST[$key] = strip_tags($value);
}
문제
Is it in any way possible to replace all single PHP $_POST['diffentOnEachPage'] elements with strip_tags($_POST['diffentOnEachPage'])
Around 50% of my $_POST elements already contain strip_tags() but some don't.
What would be the best way to approach this without finding each one and adding strip_tags() individually? - Ideally using Notepad++
해결책
Alternate way would be to remove it from everywhere and just do
foreach ($_POST as $key => $value){
$_POST[$key] = strip_tags($value);
}
다른 팁
Since you already have occurrences of strip_tags($_POST['baz']) you need to be careful not to add strip_tags to those. To do this you'll want to do negative lookbehind for 'strip_tags' and only replace the remaining instances.
Another catch - $_POST['foo'] wrapped inside a different function - you'll want to preserve the trailing ) when wrapping.
This should do the trick. I'm sure this can break in a number of other ways, but someone smarter than me can fix that :)
I tested this on Notepad++ 6.5.1.
Find what:
(?<!strip_tags\()(\$_POST\['.*'\])
Replace with:
strip_tags\((\1)\)
Input:
$_POST['foo']
strip_tags($_POST['baz'])
another_function($_POST['bar'])
Output:
strip_tags($_POST['foo'])
strip_tags($_POST['baz'])
another_function(strip_tags($_POST['bar']))
Use search and replace.
Search (\$_POST\['.*'\]) and replace by strip_tags(\1)