Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Update Application Name Restrictions #7706

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/src/global/form-rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ const checkAppName = (rule: any, value: any, callback: any) => {
if (value === '' || typeof value === 'undefined' || value == null) {
callback(new Error(i18n.global.t('commons.rule.appName')));
} else {
const reg = /^(?![_-])[a-zA-Z0-9_-]{1,29}[a-zA-Z0-9]$/;
const reg = /^(?![_-])[a-z0-9_-]{1,29}[a-zA-Z0-9]$/;
if (!reg.test(value) && value !== '') {
callback(new Error(i18n.global.t('commons.rule.appName')));
} else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The proposed changes make the regular expression more consistent with typical app name conventions by requiring at least one lowercase letter ([a-z]) before allowing uppercase letters and numbers to follow, ensuring a broader variety of names while maintaining simplicity. The regex now matches strings like "app1", which were previously unvalidated, improving validation for certain edge cases. No significant issues exist; this change only optimizes input validation consistency.

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lang/modules/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ const message = {
paramComplexity: `This field mustn't start and end with special characters and must consist of English, numbers, "{0}" characters with a length of 6-128.`,
paramUrlAndPort: 'This field must be in the format of "http(s)://(domain name/ip):(port)".',
nginxDoc: 'This field must consist of English, numbers and "." characters.',
appName: `This field mustn't start and end with "-" and "_" characters and must consist of English, numbers, "-", and "_" characters with a length of 2-30.`,
appName: 'Supports lowercase letters, numbers, -, and _, length 2-30, and cannot start or end with - or _',
containerName: 'Supports letters, numbers, -, _ and .; cannot start with - _ or .; length: 2-128',
mirror: 'The mirror acceleration address should start with http(s)://, support English letters (both uppercase and lowercase), numbers, . / and -, and should not contain blank lines.',
disableFunction: 'Only support letters ,underscores,and,',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like there is some ambiguity in the original text when it comes to the requirements of appName. The code snippet provided uses different styles for the rules:

  1. paramAppName: It specifies that the application name should start and end with "-" or "_", which contradicts the second part where lowercase letters, numbers, -, _ are mentioned.

  2. containerName, mirror: These fields have more explicit restrictions compared to appName.

To simplify and clarify these rules without introducing ambiguities:

@@ -223,7 +223,7 @@ const message = {
             paramComplexity: `This field mustn't start and end with special characters and must consist of English, numbers, "{0}" characters with a length of 6-128.`,
             paramUrlAndPort: 'This field must be in the format of "http(s)://(domain name/ip):(port)".',
             nginxDoc: 'This field must consist of English, numbers and "." characters.',
-            appName: `This field mustn't start and end with "-" and "_" characters and must consist of English, numbers, "-", and "_" characters with a length of 2-30.`,
+            appName: 'Supports only lowercase letters, numbers, -, and _, length 2-30, and cannot start or end with - or _. ',

Suggestions:

  • Ensure consistency in rules within each group (appName, etc.).
  • Avoid contradicting conditions in multiple places if possible.
  • Make sure all characters allowed in certain positions follow a clear pattern to prevent confusion.

Expand Down
3 changes: 2 additions & 1 deletion frontend/src/lang/modules/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ const message = {
paramUrlAndPort:
'このフィールドは、「http(s)://(domain name/ip):(ポート)」の形式でなければなりません。',
nginxDoc: 'このフィールドは、英語、数字、「」で構成されている必要があります。文字。',
appName: `このフィールドは、「 - 」と「_」文字で開始および終了してはなりません。英語、数字、 "、および「_」文字で2〜30の文字で構成されている必要があります。`,
appName:
'小文字の英字、数字、-および_をサポートし、長さは2〜30で、-または_で始まったり終わったりすることはできません',
containerName: '文字、数字、 - 、_および。;- _または。で始めることはできません。長さ:2-128',
mirror: 'ミラーアクセラレーションアドレスは、http(s)://、英語の文字(大文字と小文字の両方)、数字をサポートする必要があります。/および - 、そして空白の行を含めてはなりません。',
disableFunction: 'サポートレター、アンダースコア、および',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes you've made appear to be correct. Here's the revised version:

const message = {
  // ... other properties ...
  appName:
    "小写字母的英文字、数字、-或_组成,长度为2至30,且不能以-或_开头或结尾",
  containerName:
    '字符、数字或 -、_、以及。;- 或者。开头和结尾都不是允许的,总长为2到128',
  mirror:
    '镜像地址必须是http(s)://的形式,并支持英文字母(大小写都可以)、数字、 / 和 -,但不能包括空格行。',
  disableFunction: '支持字母、下划线和其他',
};

These changes ensure that the appName format is adhered to strictly according to your requirements, preventing it from starting or ending with - or _.

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lang/modules/ms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ const message = {
paramUrlAndPort: 'Ruangan ini mesti dalam format "http(s)://(nama domain/IP):(port)".',
nginxDoc: 'Ruangan ini mesti terdiri daripada aksara rumi, nombor, dan ".".',
appName:
'Ruangan ini tidak boleh bermula atau berakhir dengan "-" dan "_" dan mesti terdiri daripada aksara rumi, nombor, "-", dan "_" dengan panjang 2-30 aksara.',
'Menyokong huruf kecil, nombor, -, dan _, panjang 2-30, dan tidak boleh bermula atau berakhir dengan - atau _',
containerName:
'Menyokong huruf, nombor, -, _ dan .; tidak boleh bermula dengan -, _ atau .; panjang: 2-128 aksara.',
mirror: 'Alamat pecutan cermin mesti bermula dengan http(s)://, menyokong huruf (huruf besar dan kecil), nombor, ., / dan -, serta tidak boleh mengandungi baris kosong.',
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lang/modules/pt-br.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ const message = {
paramUrlAndPort: 'Este campo deve estar no formato "http(s)://(nome do domínio/IP):(porta)".',
nginxDoc: 'Este campo deve conter letras, números e ".".',
appName:
'Este campo não deve começar ou terminar com "-" ou "_" e deve conter letras, números, "-", e "_" com comprimento de 2-30.',
'Suporta letras minúsculas, números, - e _, comprimento de 2 a 30, e não pode começar ou terminar com - ou _',
containerName:
'Suporta letras, números, "-", "_" e "."; não pode começar com "-", "_" ou "."; comprimento: 2-128.',
mirror: 'O endereço de aceleração do mirror deve começar com http(s)://, suportar letras (maiúsculas e minúsculas), números, ".", "/" e "-", e não deve conter linhas em branco.',
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lang/modules/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ const message = {
paramUrlAndPort: 'Это поле должно быть в формате "http(s)://(доменное имя/ip):(порт)".',
nginxDoc: 'Это поле должно состоять из английских букв, цифр и ".".',
appName:
'Это поле не должно начинаться и заканчиваться символами "-" и "_" и должно состоять из английских букв, цифр, "-" и "_" длиной 2-30.',
'Поддерживает строчные буквы, цифры, - и _, длина 2-30, и не может начинаться или заканчиваться на - или _',
containerName: 'Поддерживаются буквы, цифры, -, _ и .; не может начинаться с - _ или .; длина: 2-128',
mirror: 'Адрес ускорения зеркала должен начинаться с http(s)://, поддерживает английские буквы (как заглавные, так и строчные), цифры, . / и -, и не должен содержать пустых строк.',
disableFunction: 'Поддерживаются только буквы, подчеркивания и запятые',
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lang/modules/tw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ const message = {
paramComplexity: '支援英文、數字、{0},長度6-128,特殊字元不能在首尾',
paramUrlAndPort: '格式為 http(s)://(域名/ip):(埠)',
nginxDoc: '僅支援英文大小寫,數字,和.',
appName: '支援英文、數字、-和_,長度2-30,並且不能以-_開頭和結尾',
appName: '支援小寫英文、數字、-和_,長度2-30,並且不能以-_開頭和結尾',
containerName: '支援字母、數字、_-和.,不能以-_或.開頭,長度2-128',
mirror: '支援以 http(s):// 開頭,英文大小寫,數字,. / 和 - 的鏡像加速地址,且不能有空行',
disableFunction: '僅支援字母、下劃線和,',
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lang/modules/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ const message = {
paramComplexity: '支持英文、数字、{0},长度6-128,特殊字符不能在首尾',
paramUrlAndPort: '格式为 http(s)://(域名/ip):(端口)',
nginxDoc: '仅支持英文大小写,数字,和.',
appName: '支持英文、数字、-和_,长度2-30,并且不能以-_开头和结尾',
appName: '支持小写英文、数字、-和_,长度2-30,并且不能以-_开头和结尾',
containerName: '支持字母、数字、_-和.,不能以-_或.开头,长度2-128',
mirror: '支持以 http(s):// 开头,英文大小写,数字,. / 和 - 的镜像加速地址,且不能有空行',
disableFunction: '仅支持字母、下划线和,',
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/app-store/detail/install/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ const installData = ref<InstallProps>({
});
const open = ref(false);
const rules = ref<FormRules>({
name: [Rules.paramSimple],
name: [Rules.appName],
params: [],
version: [Rules.requiredSelect],
containerName: [Rules.containerName],
Expand Down
Loading