fix: 接口调用恶意删除文件漏洞
This commit is contained in:
parent
45dc9640ed
commit
d2296fb6d2
|
@ -28,8 +28,9 @@ public class ResourceService {
|
|||
}
|
||||
|
||||
public ResponseEntity<FileSystemResource> getMdImage(String name) {
|
||||
if (name.contains("/"))
|
||||
if (name.contains("/")) {
|
||||
MSException.throwException(Translator.get("invalid_parameter"));
|
||||
}
|
||||
File file = new File(FileUtils.MD_IMAGE_DIR + "/" + name);
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
String fileName = encodeFileName(file.getName());
|
||||
|
@ -65,6 +66,9 @@ public class ResourceService {
|
|||
}
|
||||
|
||||
public void mdDelete(String fileName) {
|
||||
if (fileName.contains("/")) {
|
||||
MSException.throwException(Translator.get("invalid_parameter"));
|
||||
}
|
||||
FileUtils.deleteFile(FileUtils.MD_IMAGE_DIR + "/" + fileName);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue