mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-09-08 12:57:13 +08:00
fix(system/storage): 对象存储配置增加 Endpoint 参数格式校验
This commit is contained in:
@@ -60,9 +60,14 @@ public class RegexConstants {
|
|||||||
public static final String PACKAGE_NAME = "^(?:[a-zA-Z_][a-zA-Z0-9_]*\\.)*[a-zA-Z_][a-zA-Z0-9_]*$";
|
public static final String PACKAGE_NAME = "^(?:[a-zA-Z_][a-zA-Z0-9_]*\\.)*[a-zA-Z_][a-zA-Z0-9_]*$";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HTTP 域名 URL 正则(非 IP 地址)
|
* HTTP URL 正则
|
||||||
*/
|
*/
|
||||||
public static final String HTTP_DOMAIN_URL = "^(https?:\\/\\/)([a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,}(\\/[^\\s]*)?$";
|
public static final String URL_HTTP = "^(https?)://[\\w-+&@#/%?=~_|!:,.;]*[\\w-+&@#/%=~_|]$";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HTTP URL 正则(非 IP 地址)
|
||||||
|
*/
|
||||||
|
public static final String URL_HTTP_NOT_IP = "^(https?:\\/\\/)([a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,}(\\/[^\\s]*)?$";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HTTP HOST 正则
|
* HTTP HOST 正则
|
||||||
|
@@ -65,7 +65,7 @@ public enum StorageTypeEnum implements BaseEnum<Integer> {
|
|||||||
public void validate(StorageReq req) {
|
public void validate(StorageReq req) {
|
||||||
ValidationUtils.validate(req, ValidationGroup.Storage.OSS.class);
|
ValidationUtils.validate(req, ValidationGroup.Storage.OSS.class);
|
||||||
ValidationUtils.throwIf(StrUtil.isNotBlank(req.getDomain()) && !ReUtil
|
ValidationUtils.throwIf(StrUtil.isNotBlank(req.getDomain()) && !ReUtil
|
||||||
.isMatch(RegexConstants.HTTP_DOMAIN_URL, req.getDomain()), "域名格式不正确");
|
.isMatch(RegexConstants.URL_HTTP_NOT_IP, req.getDomain()), "域名格式不正确");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -88,6 +88,7 @@ public class StorageReq implements Serializable {
|
|||||||
@Schema(description = "Endpoint", example = "")
|
@Schema(description = "Endpoint", example = "")
|
||||||
@Length(max = 255, message = "Endpoint长度不能超过 {max} 个字符")
|
@Length(max = 255, message = "Endpoint长度不能超过 {max} 个字符")
|
||||||
@NotBlank(message = "Endpoint不能为空", groups = ValidationGroup.Storage.OSS.class)
|
@NotBlank(message = "Endpoint不能为空", groups = ValidationGroup.Storage.OSS.class)
|
||||||
|
@Pattern(regexp = RegexConstants.URL_HTTP, message = "Endpoint格式不正确", groups = ValidationGroup.Storage.OSS.class)
|
||||||
private String endpoint;
|
private String endpoint;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user