-
Notifications
You must be signed in to change notification settings - Fork 25
EVG-20817: Restrict special characters in project name & ID input #2099
Conversation
1 failed test on run #13273 ↗︎
Details:
Review all test suite changes for PR #2099 ↗︎ |
src/utils/validators/index.ts
Outdated
const validateNoSpecialCharacters = (str: string): boolean => { | ||
const noSpecialCharacters = /^[0-9a-zA-Z-._~()]*$/; |
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.
It could be cool to define these special chars as a var that can be used in the error message so that any updates are reflected. I think this would work
const validateNoSpecialCharacters = (str: string): boolean => { | |
const noSpecialCharacters = /^[0-9a-zA-Z-._~()]*$/; | |
const specialChars = "-._~()"; | |
const validateNoSpecialCharacters = (str: string): boolean => { | |
const noSpecialCharacters = new RegExp(`^[0-9a-zA-Z${specialChars}]*$`); |
} | ||
|
||
return `${paths.project}/${projectId}/${PageNames.Settings}/${tab}`; | ||
const encodedProjectId = encodeURIComponent(projectId); |
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 description says we don't need to encode the URL, should this be included
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.
This is for backwards compatibility, I'll make a comment in the code
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.
Nice -- since the ticket mentions that we'll work with project admins to change their project identifiers, can we update the comment to note that we'll delete this when that is done?
} | ||
|
||
return `${paths.project}/${projectId}/${PageNames.Settings}/${tab}`; | ||
const encodedProjectId = encodeURIComponent(projectId); |
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.
Nice -- since the ticket mentions that we'll work with project admins to change their project identifiers, can we update the comment to note that we'll delete this when that is done?
EVG-20817
Description
The validation matches that in EVG so none of the characters require escaping in the URL.
Screenshots
Testing
Evergreen PR