mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-10 11:26:50 +08:00
路径遍历
This commit is contained in:
@@ -66,6 +66,10 @@ public class ExcelToPdfConverter implements ICourseFileConverter {
|
||||
|
||||
@Override
|
||||
public String convert(String fileType, String filePath) throws Exception{
|
||||
if (filePath.contains("..")) {
|
||||
throw new SecurityException("输入路径包含不安全的字符");
|
||||
}
|
||||
|
||||
if (this.getLicense()) {
|
||||
FileOutputStream fileOS=null;
|
||||
String previewPath = null;
|
||||
|
||||
@@ -65,6 +65,10 @@ public class PPTToPdfConverter implements ICourseFileConverter {
|
||||
|
||||
@Override
|
||||
public String convert(String fileType, String filePath) throws Exception{
|
||||
if (filePath.contains("..")) {
|
||||
throw new SecurityException("输入路径包含不安全的字符");
|
||||
}
|
||||
|
||||
if (this.getLicense()) {
|
||||
InputStream slides=null;
|
||||
Presentation pres=null;
|
||||
|
||||
@@ -69,6 +69,10 @@ public class WordToPdfConverter implements ICourseFileConverter {
|
||||
|
||||
@Override
|
||||
public String convert(String fileType, String filePath) throws Exception{
|
||||
if (filePath.contains("..")) {
|
||||
throw new SecurityException("输入路径包含不安全的字符");
|
||||
}
|
||||
|
||||
if (this.getLicense()) {
|
||||
File pdfFile=null;
|
||||
FileOutputStream fileOS=null;
|
||||
|
||||
@@ -227,6 +227,10 @@ public class CourseFileApi extends ApiBaseController {
|
||||
return badRequest("请先选择资源归属");
|
||||
}
|
||||
|
||||
if (file.getFilePath().contains("..")) {
|
||||
throw new SecurityException("输入路径包含不安全的字符");
|
||||
}
|
||||
|
||||
// 重设文件类型为小写
|
||||
file.setFileType(file.getFileType().toLowerCase());
|
||||
|
||||
@@ -395,8 +399,15 @@ public class CourseFileApi extends ApiBaseController {
|
||||
//return badRequest("参数错误");
|
||||
return;
|
||||
}
|
||||
|
||||
String cfPath=null;
|
||||
|
||||
if (cf.contains("..")) {
|
||||
log.error("参数错误");
|
||||
// throw new SecurityException("输入路径包含不安全的字符");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
String cfPath=null;
|
||||
String fileName ="";
|
||||
if(StringUtils.isNotBlank(cf)) {
|
||||
cfPath=cf;
|
||||
|
||||
Reference in New Issue
Block a user