提交 bb8713b6 编写于 作者: D devil_gong

小程序包删除,防止路径回溯

上级 6707ddce
......@@ -187,9 +187,21 @@ class AppMiniService
// 初始化
self::Init($params);
// 目录处理
$suffix = '';
if(substr($params['id'], -4) === '.zip')
{
$name = substr($params['id'], 0, strlen($params['id'])-4);
$suffix = '.zip';
} else {
$name = $params['id'];
}
// 防止路径回溯
$path = self::$new_path.DS.htmlentities(str_replace(array('.', '/', '\\'), '', strip_tags($name))).$suffix;
// 删除压缩包
$path = self::$new_path.DS.$params['id'];
if(substr($path, -4) == '.zip')
if($suffix == '.zip')
{
$status = \base\FileUtil::UnlinkFile($path);
} else {
......
......@@ -174,8 +174,8 @@ class ThemeService
{
return DataReturn('模板id有误', -1);
}
// 主题
$id = str_replace(array('.', '/', '\\'), '', strip_tags($params['id']));
// 防止路径回溯
$id = htmlentities(str_replace(array('.', '/', '\\'), '', strip_tags($params['id'])));
if(empty($id))
{
return DataReturn('主题名称有误', -1);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册