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

Username cannot include special characters #9703

Merged
merged 3 commits into from
Sep 20, 2023
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
7 changes: 7 additions & 0 deletions changelog/unreleased/bugfix-username-validation
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Bugfix: Special characters in username

Preventing special characters except for . and _ in the username.
Matching server validation for username

https://github.com/owncloud/web/issues/9694
https://github.com/owncloud/web/pull/9703
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,19 @@ export default defineComponent({
return false
}

// validate username against regex
// shouldn't contain special characters except . and _
// shouldn't start with a number
// matching regex from server side
const pattern =
"^[a-zA-Z_][a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]*(@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)*$"
if (!new RegExp(pattern).test(this.user.onPremisesSamAccountName)) {
this.formData.userName.errorMessage = this.$gettext(
'User name cannot contain special characters'
)
return false
}

if (
this.user.onPremisesSamAccountName.length &&
!isNaN(parseInt(this.user.onPremisesSamAccountName[0]))
Expand Down