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: Panel aliases support common special characters #7654

Merged
merged 2 commits into from
Jan 7, 2025

Conversation

lan-yonghui
Copy link
Member

Refs #6909

Copy link

f2c-ci-robot bot commented Jan 7, 2025

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@@ -67,7 +67,7 @@ function checkPanelName(rule: any, value: any, callback: any) {
if (value === '') {
return callback(new Error(i18n.global.t('setting.titleHelper')));
}
const reg = /^[a-zA-Z0-9\u4e00-\u9fa5]{1}[a-zA-Z0-9_ .\u4e00-\u9fa5-]{2,29}$/;
const reg = /^[a-zA-Z0-9\u4e00-\u9fa5 .,:!@#%&^*_+\[\]{}~\-=?,。!|?:;「」『』【】()《》·]{3,30}$/;
if (!reg.test(value)) {
return callback(new Error(i18n.global.t('setting.titleHelper')));
}
Copy link
Member

Choose a reason for hiding this comment

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

The regular expression in your function has been modified to allow more characters, such as punctuation marks and symbols. While this might be necessary based on specific requirements, it may also result in validation errors that were previously acceptable due to the stricter pattern defined initially. It's recommended to thoroughly test with various inputs (including edge cases) to ensure correct functionality.

Additionally, consider adding a comment explanation of why the change was made, especially since reg is reused elsewhere in your codebase. This could help maintain clarity for other developers who work on this part of the code in the future.

@@ -67,7 +67,7 @@ function checkPanelName(rule: any, value: any, callback: any) {
if (value === '') {
return callback(new Error(i18n.global.t('setting.titleHelper')));
}
const reg = /^[a-zA-Z0-9\u4e00-\u9fa5]{1}[a-zA-Z0-9_ .\u4e00-\u9fa5-]{2,29}$/;
const reg = /^[a-zA-Z0-9\u4e00-\u9fa5 .,:!@#%&^*_+[\]{}~\-=?,。!|?:;「」『』【】()《》·]{3,30}$/;
if (!reg.test(value)) {
return callback(new Error(i18n.global.t('setting.titleHelper')));
}
Copy link
Member

Choose a reason for hiding this comment

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

The provided code difference introduces an updated regex pattern that allows alphanumeric characters including some special symbols such as .,:!@#%&^*_+\[\]{}~-=?,。!|?:;「」『』【】()《》·. This change aims to allow a wider range of valid panel name inputs beyond just letters, numbers, and underscores. The main consideration is security; allowing these additional punctuation marks could potentially be exploited inappropriately to bypass legitimate input validation checks.

Optimization suggestion:
It may be worth considering whether the current requirement to have at least two characters and up to thirty is necessary given the flexibility with new allowed characters. Simplifying this condition could make it clearer without losing significant functionality.

Potential issue:
Allowing more complex patterns might increase complexity when integrating with other parts of the application or services where strict rules on character usage are required.

"change": {
  "regex": "^\\w{3,30}$
}

This would restrict the rule to only accept words consisting of alphanumeric characters and underscore, which aligns closely with common naming conventions used across many systems and applications while maintaining minimal risk and simplicity of integration into existing workflows.

Copy link

sonarqubecloud bot commented Jan 7, 2025

Copy link
Member

@wanghe-fit2cloud wanghe-fit2cloud left a comment

Choose a reason for hiding this comment

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

/lgtm

@wanghe-fit2cloud
Copy link
Member

/approve

Copy link

f2c-ci-robot bot commented Jan 7, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: wanghe-fit2cloud

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@f2c-ci-robot f2c-ci-robot bot added the approved label Jan 7, 2025
@f2c-ci-robot f2c-ci-robot bot merged commit 2392f91 into dev Jan 7, 2025
6 checks passed
@f2c-ci-robot f2c-ci-robot bot deleted the pr@dev@fix_panel_name branch January 7, 2025 04:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants