fix(system/storage): 对象存储配置增加 Endpoint 参数格式校验

This commit is contained in:
2025-08-20 22:00:50 +08:00
parent b305dd7e53
commit f2258d821b
3 changed files with 9 additions and 3 deletions

View File

@@ -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_]*$";
/**
* 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 正则

View File

@@ -65,7 +65,7 @@ public enum StorageTypeEnum implements BaseEnum<Integer> {
public void validate(StorageReq req) {
ValidationUtils.validate(req, ValidationGroup.Storage.OSS.class);
ValidationUtils.throwIf(StrUtil.isNotBlank(req.getDomain()) && !ReUtil
.isMatch(RegexConstants.HTTP_DOMAIN_URL, req.getDomain()), "域名格式不正确");
.isMatch(RegexConstants.URL_HTTP_NOT_IP, req.getDomain()), "域名格式不正确");
}
};

View File

@@ -88,6 +88,7 @@ public class StorageReq implements Serializable {
@Schema(description = "Endpoint", example = "")
@Length(max = 255, message = "Endpoint长度不能超过 {max} 个字符")
@NotBlank(message = "Endpoint不能为空", groups = ValidationGroup.Storage.OSS.class)
@Pattern(regexp = RegexConstants.URL_HTTP, message = "Endpoint格式不正确", groups = ValidationGroup.Storage.OSS.class)
private String endpoint;
/**