【发布时间】:2022-04-06 20:15:51
【问题描述】:
<?php
if (preg_match('/^[a-z0-9]+$/', $_GET['p'])) {
$page = realpath('pages/'.$_GET['p'].'.php');
$tpl = realpath('templates/'.$_GET['p'].'.html');
if ($page && $tpl) {
include $page;
include $tpl;
} else {
include('error.php');
}
}
?>
你觉得这有多安全?
【问题讨论】:
-
\w 匹配字母数字和 _,使用它会产生与预期不同的模式