diff --git a/class/Api.php b/class/Api.php index 7e793b7..2066e95 100644 --- a/class/Api.php +++ b/class/Api.php @@ -1,7 +1,7 @@ * blog:xiaoz.me */ @@ -339,6 +339,18 @@ class Api { //过滤$filename $filename = str_replace('../','',$filename); $filename = str_replace('./','',$filename); + // 获取文件名称的后缀 + $suffix = explode('.',$filename); + // 如果没有后缀,则不合法,通过数组长度判断后缀 + if( count($suffix) < 2 ) { + $this->err_msg(-2000,'文件不合法!'); + } + // 获取文件后缀 + $suffix = strtolower(end($suffix)); + if( ( $suffix != 'html' ) && ( $suffix != 'htm' ) ) { + $this->err_msg(-2000,'文件不合法!'); + } + $this->auth($token); //检查文件是否存在 if ( !file_exists($filename) ) {