fix: Add length limit to comments (#8055)

This commit is contained in:
zhengkunwang 2025-03-03 18:46:56 +08:00 committed by GitHub
parent 660dc62f3c
commit f242f71661
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 48 additions and 15 deletions

View file

@ -7,7 +7,7 @@ import (
type WebsiteSearch struct {
dto.PageInfo
Name string `json:"name"`
OrderBy string `json:"orderBy" validate:"required,oneof=primary_domain type status createdAt expire_date"`
OrderBy string `json:"orderBy" validate:"required,oneof=primary_domain type status createdAt expire_date created_at"`
Order string `json:"order" validate:"required,oneof=null ascending descending"`
WebsiteGroupID uint `json:"websiteGroupId"`
}

View file

@ -2,7 +2,6 @@ package repo
import (
"context"
"github.com/1Panel-dev/1Panel/agent/app/model"
"github.com/1Panel-dev/1Panel/agent/global"
"gorm.io/gorm"

View file

@ -138,7 +138,7 @@ func (w WebsiteSSLService) Create(create request.WebsiteSSLCreate) (request.Webs
if create.PushDir {
fileOP := files.NewFileOp()
if !fileOP.Stat(create.Dir) {
_ = fileOP.CreateDir(create.Dir, constant.DirPerm)
return res, buserr.New("ErrLinkPathNotFound")
}
websiteSSL.Dir = create.Dir
}
@ -490,7 +490,7 @@ func (w WebsiteSSLService) Update(update request.WebsiteSSLUpdate) error {
updateParams["shell"] = ""
}
if websiteSSL.Provider != constant.SelfSigned {
if websiteSSL.Provider != constant.SelfSigned && websiteSSL.Provider != constant.Manual {
acmeAccount, err := websiteAcmeRepo.GetFirst(repo.WithByID(update.AcmeAccountID))
if err != nil {
return err

View file

@ -247,6 +247,8 @@ const message = {
phpExtension: 'Only supports , _ lowercase English and numbers',
paramHttp: 'Must start with http:// or https://',
phone: 'The format of the phone number is incorrect',
authBasicPassword: 'Supports letters, numbers, and common special characters, length 1-72',
length128Err: 'Length cannot exceed 128 characters',
},
res: {
paramError: 'The request failed, please try again later!',

View file

@ -240,6 +240,8 @@ const message = {
phpExtension: '_小文字の英語と数字のみをサポートします',
paramHttp: 'http://またはhttps://で始める必要があります',
phone: '電話番号の形式は正しくありません',
authBasicPassword: '英字数字一般的な特殊文字をサポート長さ1-72',
length128Err: '長さは128文字を超えることはできません',
},
res: {
paramError: 'リクエストが失敗しました後でもう一度やり直してください',

View file

@ -241,6 +241,8 @@ const message = {
phpExtension: '소문자 영어와 숫자, "_" 지원합니다',
paramHttp: 'http:// 또는 https:// 로 시작해야 합니다',
phone: '전화번호 형식이 올바르지 않습니다',
authBasicPassword: '알파벳, 숫자 일반 특수 문자 지원, 길이 1-72',
length128Err: '길이는 128자를 초과할 없습니다',
},
res: {
paramError: '요청이 실패했습니다. 나중에 다시 시도하세요!',

View file

@ -247,6 +247,8 @@ const message = {
phpExtension: 'Hanya menyokong huruf kecil, _, dan nombor',
paramHttp: 'Mesti bermula dengan http:// atau https://',
phone: 'Format nombor telefon tidak betul.',
authBasicPassword: 'Menyokong huruf, nombor, dan aksara khas biasa, panjang 1-72',
length128Err: 'Panjang tidak boleh melebihi 128 aksara',
},
res: {
paramError: 'Permintaan gagal, sila cuba lagi nanti!',

View file

@ -245,6 +245,8 @@ const message = {
phpExtension: 'Suporta apenas _, letras minúsculas e números',
paramHttp: 'Deve começar com http:// ou https://',
phone: 'O formato do número de telefone está incorreto',
authBasicPassword: 'Suporta letras, números e caracteres especiais comuns, comprimento 1-72',
length128Err: 'O comprimento não pode exceder 128 caracteres',
},
res: {
paramError: 'A solicitação falhou, por favor, tente novamente mais tarde!',

View file

@ -241,6 +241,8 @@ const message = {
phpExtension: 'Поддерживаются только запятые, подчеркивания, строчные английские буквы и цифры',
paramHttp: 'Должно начинаться с http:// или https://',
phone: 'Неверный формат номера телефона',
authBasicPassword: 'Поддерживает буквы, цифры и общие специальные символы, длина 1-72',
length128Err: 'Длина не может превышать 128 символов',
},
res: {
paramError: 'Запрос не удался, попробуйте позже!',

View file

@ -240,6 +240,8 @@ const message = {
phpExtension: '僅支持 , _ 小寫英文和數字',
paramHttp: '必須以 http:// 或 https:// 開頭',
phone: '手機號碼格式不正確',
authBasicPassword: '支持字母數字以及常見特殊字符長度1-72',
length128Err: '長度不能超過128位',
},
res: {
paramError: '請求失敗,請稍後重試!',

View file

@ -239,6 +239,7 @@ const message = {
paramHttp: '必须以 http:// 或 https:// 开头',
phone: '手机号码格式不正确',
authBasicPassword: '支持字母数字以及常见特殊字符长度1-72',
length128Err: '长度不能超过128位',
},
res: {
paramError: '请求失败,请稍后重试!',

View file

@ -108,7 +108,7 @@
<template #default="{ row }">
<fu-read-write-switch>
<template #read>
<MsgInfo :info="row.description" />
<MsgInfo :info="row.description" width="180px" />
</template>
<template #default="{ read }">
<el-input v-model="row.description" @blur="updateDesc(row, read)" />
@ -167,7 +167,7 @@ import Detail from './detail/index.vue';
import { dateFormat, getProvider } from '@/utils/util';
import i18n from '@/lang';
import { Website } from '@/api/interface/website';
import { MsgSuccess } from '@/utils/message';
import { MsgError, MsgSuccess } from '@/utils/message';
import { GlobalStore } from '@/store';
import SSLUpload from './upload/index.vue';
import Apply from './apply/index.vue';
@ -300,6 +300,10 @@ const search = () => {
const updateDesc = (row: Website.SSLDTO, bulr: Function) => {
bulr();
if (row.description && row.description.length > 128) {
MsgError(i18n.global.t('commons.rule.length128Err'));
return;
}
updateConfig(row);
};

View file

@ -152,12 +152,18 @@
/>
</template>
</el-table-column>
<el-table-column
:label="$t('website.remark')"
prop="remark"
show-overflow-tooltip
min-width="120px"
></el-table-column>
<el-table-column :label="$t('website.remark')" prop="remark" min-width="120px">
<template #default="{ row }">
<fu-read-write-switch>
<template #read>
<MsgInfo :info="row.remark" width="180px" />
</template>
<template #default="{ read }">
<el-input v-model="row.remark" @blur="updateRemark(row, read)" />
</template>
</fu-read-write-switch>
</template>
</el-table-column>
<el-table-column
:label="$t('commons.table.protocol')"
prop="protocol"
@ -179,7 +185,7 @@
:disabled-date="checkDate"
:shortcuts="shortcuts"
:clearable="false"
@change="submitDate(row)"
@change="updateWebsitConfig(row)"
:ref="(el) => setdateRefs(el)"
@visible-change="(visibility:boolean) => pickerVisibility(visibility, row)"
size="small"
@ -255,7 +261,7 @@ import { Website } from '@/api/interface/website';
import { App } from '@/api/interface/app';
import { ElMessageBox } from 'element-plus';
import { dateFormatSimple } from '@/utils/util';
import { MsgSuccess } from '@/utils/message';
import { MsgError, MsgSuccess } from '@/utils/message';
import { useI18n } from 'vue-i18n';
import { getAgentGroupList } from '@/api/modules/group';
import { Group } from '@/api/interface/group';
@ -427,7 +433,7 @@ const pickerVisibility = (visibility: boolean, row: any) => {
}
};
const submitDate = (row: any) => {
const updateWebsitConfig = (row: any) => {
const reqDate = dateFormatSimple(row.expireDate);
const req = {
id: row.id,
@ -550,6 +556,15 @@ const getUrl = (domain: Website.Domain, website: Website.Website): string => {
return url;
};
const updateRemark = (row: Website.Website, bulr: Function) => {
bulr();
if (row.remark && row.remark.length > 128) {
MsgError(i18n.global.t('commons.rule.length128Err'));
return;
}
updateWebsitConfig(row);
};
onMounted(() => {
search();
listGroup();