diff --git a/backend/app/api/v1/file.go b/backend/app/api/v1/file.go index fc0f7dc51..9d969e743 100644 --- a/backend/app/api/v1/file.go +++ b/backend/app/api/v1/file.go @@ -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 diff --git a/frontend/src/global/form-rules.ts b/frontend/src/global/form-rules.ts index 3a0bebe9a..f3b7e509c 100644 --- a/frontend/src/global/form-rules.ts +++ b/frontend/src/global/form-rules.ts @@ -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, + }, }; diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 3317d3795..5617c9e6a 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -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!', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 2b8a46a42..9da4399b1 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -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: '请求失败,请稍后重试!',