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