🔨 优化 sftp 代码逻辑.
This commit is contained in:
@@ -77,4 +77,6 @@ public interface ErrorMessage {
|
||||
|
||||
String CONNECT_ERROR = "连接失败";
|
||||
|
||||
String PATH_NOT_NORMALIZE = "路径不合法";
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.orion.ops.framework.common.utils;
|
||||
|
||||
import com.orion.lang.utils.Arrays1;
|
||||
import com.orion.lang.utils.io.Files1;
|
||||
import com.orion.ops.framework.common.constant.ErrorMessage;
|
||||
import com.orion.spring.SpringHolder;
|
||||
|
||||
@@ -116,4 +117,15 @@ public class Valid extends com.orion.lang.utils.Valid {
|
||||
return effect;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查路径是否合法化 即不包含 ./ ../
|
||||
*
|
||||
* @param path path
|
||||
*/
|
||||
public static String checkNormalize(String path) {
|
||||
Valid.notBlank(path);
|
||||
Valid.isTrue(Files1.isNormalize(path), ErrorMessage.PATH_NOT_NORMALIZE);
|
||||
return Files1.getPath(path);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user