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

feat/task1-c-wallet
devil_gong 2019-01-04 18:16:20 +08:00
parent 6707ddcec8
commit bb8713b6f8
2 changed files with 16 additions and 4 deletions

View File

@ -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 {

View File

@ -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);