mirror of https://github.com/1Panel-dev/1Panel
fix: 解决 halo 用户名设置为大写之后导致安装失败的问题 (#1190)
Refs https://github.com/1Panel-dev/1Panel/issues/1161pull/1192/head
parent
ce0342e235
commit
1e96a1ae84
|
@ -456,19 +456,14 @@ func (b *BaseApi) MoveFile(c *gin.Context) {
|
|||
// @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFuntions":[],"formatZH":"下载文件 [name]","formatEN":"Download file [name]"}
|
||||
func (b *BaseApi) Download(c *gin.Context) {
|
||||
filePath := c.Query("path")
|
||||
|
||||
file, err := os.Open(filePath)
|
||||
if err != nil {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||
}
|
||||
|
||||
info, _ := file.Stat()
|
||||
|
||||
c.Header("Content-Length", strconv.FormatInt(info.Size(), 10))
|
||||
c.Header("Content-Disposition", "attachment; filename*=utf-8''"+url.PathEscape(info.Name()))
|
||||
|
||||
http.ServeContent(c.Writer, c.Request, info.Name(), info.ModTime(), file)
|
||||
return
|
||||
}
|
||||
|
||||
// @Tags File
|
||||
|
|
|
@ -191,7 +191,7 @@ const checkParamCommon = (rule: any, value: any, callback: any) => {
|
|||
if (value === '' || typeof value === 'undefined' || value == null) {
|
||||
callback(new Error(i18n.global.t('commons.rule.paramName')));
|
||||
} else {
|
||||
const reg = /^[a-zA-Z0-9]{1}[a-zA-Z0-9._-]{1,29}$/;
|
||||
const reg = /^[a-zA-Z0-9]{1}[a-zA-Z0-9._-]{1,63}$/;
|
||||
if (!reg.test(value) && value !== '') {
|
||||
callback(new Error(i18n.global.t('commons.rule.paramName')));
|
||||
} else {
|
||||
|
@ -204,7 +204,7 @@ const checkParamComplexity = (rule: any, value: any, callback: any) => {
|
|||
if (value === '' || typeof value === 'undefined' || value == null) {
|
||||
callback(new Error(i18n.global.t('commons.rule.paramComplexity', ['.%@$!&~_-'])));
|
||||
} else {
|
||||
const reg = /^[a-zA-Z0-9]{1}[a-zA-Z0-9.%@$!&~_-]{5,29}$/;
|
||||
const reg = /^[a-zA-Z0-9]{1}[a-zA-Z0-9.%@$!&~_-]{5,127}$/;
|
||||
if (!reg.test(value) && value !== '') {
|
||||
callback(new Error(i18n.global.t('commons.rule.paramComplexity', ['.%@$!&~_-'])));
|
||||
} else {
|
||||
|
@ -303,6 +303,19 @@ const checkLeechExts = (rule: any, value: any, callback: any) => {
|
|||
}
|
||||
};
|
||||
|
||||
const checkParamSimple = (rule: any, value: any, callback: any) => {
|
||||
if (value === '' || typeof value === 'undefined' || value == null) {
|
||||
callback();
|
||||
} else {
|
||||
const reg = /^[a-z0-9][a-z0-9]{1,64}$/;
|
||||
if (!reg.test(value) && value !== '') {
|
||||
callback(new Error(i18n.global.t('commons.rule.paramSimple')));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
interface CommonRule {
|
||||
requiredInput: FormItemRule;
|
||||
requiredSelect: FormItemRule;
|
||||
|
@ -333,6 +346,7 @@ interface CommonRule {
|
|||
paramComplexity: FormItemRule;
|
||||
paramPort: FormItemRule;
|
||||
paramExtUrl: FormItemRule;
|
||||
paramSimple: FormItemRule;
|
||||
}
|
||||
|
||||
export const Rules: CommonRule = {
|
||||
|
@ -484,4 +498,9 @@ export const Rules: CommonRule = {
|
|||
trigger: 'blur',
|
||||
validator: checkLeechExts,
|
||||
},
|
||||
paramSimple: {
|
||||
required: true,
|
||||
trigger: 'blur',
|
||||
validator: checkParamSimple,
|
||||
},
|
||||
};
|
||||
|
|
|
@ -162,6 +162,7 @@ const message = {
|
|||
'Supports letters, numbers, underscores, hyphens and dots, cannot end with hyphen- or dot.1-127',
|
||||
disableFunction: 'Only support letters and,',
|
||||
leechExts: 'Only support letters, numbers and,',
|
||||
paramSimple: 'Support lowercase letters and numbers, length 1-64',
|
||||
},
|
||||
res: {
|
||||
paramError: 'The request failed, please try again later!',
|
||||
|
|
|
@ -156,14 +156,15 @@ const message = {
|
|||
databaseName: '支持英文、数字、_,长度1-30',
|
||||
ipErr: 'IP [{0}] 格式错误,请检查',
|
||||
numberRange: '数字范围: {0} - {1}',
|
||||
paramName: '支持英文、数字、.-和_,长度2-30',
|
||||
paramComplexity: '支持英文、数字、{0},长度6-30,特殊字符不能在首尾',
|
||||
paramName: '支持英文、数字、.-和_,长度2-64',
|
||||
paramComplexity: '支持英文、数字、{0},长度6-128,特殊字符不能在首尾',
|
||||
paramUrlAndPort: '格式为 http(s)://(域名/ip):(端口)',
|
||||
nginxDoc: '仅支持英文大小写,数字,和.',
|
||||
appName: '支持英文、数字、-和_,长度2-30,并且不能以-_开头和结尾',
|
||||
conatinerName: '支持字母、数字、下划线、连字符和点,不能以连字符-或点.结尾,长度1-127',
|
||||
disableFunction: '仅支持字母和,',
|
||||
leechExts: '件支持字母数字和,',
|
||||
paramSimple: '支持小写字母和数字,长度1-64',
|
||||
},
|
||||
res: {
|
||||
paramError: '请求失败,请稍后重试!',
|
||||
|
|
Loading…
Reference in New Issue