I want to filter user input like this:
$data = file_get_contents('php://input');
if ($data != null && $data !=='') {
$parsedData = json_decode($data, true);
}
// find quickmodule name
$moduleName = $_GET['module'];
// validate name
if (! preg_match("/^[0-9a-z]+$/i", $moduleName)) {
die("Invalid quickmodule name");
}
// check if exists
$modulePath "/quick/".$moduleName.".php";
if (file_exists($modulePath)) {
require_once($modulePath);
Does this solution really save me, and is it possible to bypass it in modern PHP? Tricks with newline did not work.
if (! preg_match("/^[0-9a-z]+$/i", $moduleName)) {
die("Invalid quickmodule name");
}