Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 67 additions & 37 deletions src/main/java/com/jmal/clouddisk/controller/rest/FileController.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ public ResponseResult<Object> deleteDraft(@RequestParam String fileId, @RequestP
@PostMapping("/markdown/edit1")
@Permission("cloud:file:update")
public ResponseResult<Object> editTextByPath(@RequestBody UploadApiParamDTO upload) {
ResultUtil.checkParamIsNull(upload.getUsername(), upload.getUserId(), upload.getRelativePath(), upload.getContentText());
ResultUtil.checkParamIsNull(upload.getUsername(), upload.getUserId(), upload.getRelativePath(),
upload.getContentText());
if (!CharSequenceUtil.isBlank(upload.getMountFileId())) {
FileDocument fileDocument = commonFileService.getById(upload.getMountFileId());
upload.setUserId(fileDocument.getUserId());
Expand All @@ -113,7 +114,7 @@ public ResponseResult<Object> editTextByPath(@RequestBody UploadApiParamDTO uplo
@PostMapping("/upload-markdown-image")
@Permission("cloud:file:upload")
public ResponseResult<Object> uploadMarkdownImage(UploadImageDTO upload) {
if(CharSequenceUtil.isBlank(upload.getUserId()) || CharSequenceUtil.isBlank(upload.getUsername())) {
if (CharSequenceUtil.isBlank(upload.getUserId()) || CharSequenceUtil.isBlank(upload.getUsername())) {
return ResultUtil.warning("参数里缺少 userId 或 username");
}
return markdownService.uploadMarkdownImage(upload);
Expand All @@ -123,18 +124,19 @@ public ResponseResult<Object> uploadMarkdownImage(UploadImageDTO upload) {
@PostMapping("/upload-markdown-link-image")
@Permission("cloud:file:upload")
@LogOperatingFun
public ResponseResult<Object> uploadMarkdownLinkImage(HttpServletRequest request, @RequestBody UploadImageDTO uploadImageDTO) {
public ResponseResult<Object> uploadMarkdownLinkImage(HttpServletRequest request,
@RequestBody UploadImageDTO uploadImageDTO) {
String userId = uploadImageDTO.getUserId();
String username = uploadImageDTO.getUsername();
if(CharSequenceUtil.isBlank(userId)){
if (CharSequenceUtil.isBlank(userId)) {
userId = request.getHeader("userId");
uploadImageDTO.setUserId(userId);
}
if(CharSequenceUtil.isBlank(username)){
if (CharSequenceUtil.isBlank(username)) {
username = request.getHeader("username");
uploadImageDTO.setUsername(username);
}
if(CharSequenceUtil.isBlank(userId) || CharSequenceUtil.isBlank(username)) {
if (CharSequenceUtil.isBlank(userId) || CharSequenceUtil.isBlank(username)) {
return ResultUtil.warning("请求头里或参数里必须含有userId和username");
}
return markdownService.uploadMarkdownLinkImage(uploadImageDTO);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/jmal/clouddisk/model/ArticleParamDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ public class ArticleParamDTO implements Reflective {
private LocalDateTime uploadDate;

public String getFilename() {
return FileNameUtils.safeDecode(filename);
return FileNameUtils.decodeAndCheckPath(filename);
}

public String getCurrentDirectory() {
if (currentDirectory == null || "undefined".equals(currentDirectory)) {
return null;
}
return FileNameUtils.safeDecode(currentDirectory);
return FileNameUtils.decodeAndCheckPath(currentDirectory);
}
}
8 changes: 4 additions & 4 deletions src/main/java/com/jmal/clouddisk/model/UploadApiParamDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -276,15 +276,15 @@ public class UploadApiParamDTO implements Reflective {
private LocalDateTime uploadDate;

public String getFilename() {
return FileNameUtils.safeDecode(filename);
return FileNameUtils.decodeAndCheckPath(filename);
}

public String getRelativePath() {
if (File.separator.equals("\\")) {
// Windows 系统
relativePath = relativePath.replace("/", "\\");
}
return FileNameUtils.safeDecode(relativePath);
return FileNameUtils.decodeAndCheckPath(relativePath);
}

public String getCurrentDirectory() {
Expand All @@ -295,7 +295,7 @@ public String getCurrentDirectory() {
// Windows 系统
currentDirectory = currentDirectory.replace("/", "\\");
}
return FileNameUtils.safeDecode(currentDirectory);
return FileNameUtils.decodeAndCheckPath(currentDirectory);
}

public String getFolderPath() {
Expand All @@ -306,7 +306,7 @@ public String getFolderPath() {
// Windows 系统
folderPath = folderPath.replace("/", "\\");
}
return FileNameUtils.safeDecode(folderPath);
return FileNameUtils.decodeAndCheckPath(folderPath);
}

public SearchDTO toSearchDTO() {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/jmal/clouddisk/oss/web/WebOssService.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public List<Map<String, String>> getPlatformList() {
public static String getObjectName(Path prePath, String ossPath, boolean isFolder) {
// 判断prePath是否为url编码过的,如果是则解码
String prePathStr = prePath.toString();
String decodedPathStr = FileNameUtils.safeDecode(prePathStr);
String decodedPathStr = FileNameUtils.decodeAndCheckPath(prePathStr);
if (!prePathStr.equals(decodedPathStr)) {
prePath = Paths.get(decodedPathStr);
}
Expand All @@ -138,7 +138,7 @@ public static String getObjectName(Path prePath, String ossPath, boolean isFolde
name = name + "/";
}
}
return FileNameUtils.safeDecode(name);
return FileNameUtils.decodeAndCheckPath(name);
}

public static String getFilenameFromObjectName(String objectName) {
Expand Down
Loading
Loading