提交 bb8713b6 编写于 作者: D devil_gong

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

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