-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Conversation
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'))); | |||
} |
There was a problem hiding this comment.
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'))); | |||
} |
There was a problem hiding this comment.
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.
Quality Gate passedIssues Measures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve |
[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 |
Refs #6909