Skip to content

Commit

Permalink
Fixed regex bug in Safari (#89399)
Browse files Browse the repository at this point in the history
* Fixed regex bug in Safari

* Added extra unit test
  • Loading branch information
thomheymann authored Jan 27, 2021
1 parent ba1e795 commit 6425c5d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion x-pack/plugins/security/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const NEXT_URL_QUERY_STRING_PARAMETER = 'next';
* - Must contain only letters, numbers, spaces, punctuation and printable symbols.
* - Must not contain leading or trailing spaces.
*/
export const NAME_REGEX = /^(?! )[a-zA-Z0-9 !"#$%&'()*+,\-./\\:;<=>?@\[\]^_`{|}~]+(?<! )$/;
export const NAME_REGEX = /^(?! )[a-zA-Z0-9 !"#$%&'()*+,\-./\\:;<=>?@\[\]^_`{|}~]*[a-zA-Z0-9!"#$%&'()*+,\-./\\:;<=>?@\[\]^_`{|}~]$/;

/**
* Maximum length of usernames and role names.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ describe('CreateUserPage', () => {

await findAllByText(/Username must not contain leading or trailing spaces/i);

fireEvent.change(await findByLabelText('Username'), {
target: { value: 'username_with_trailing_space ' },
});

await findAllByText(/Username must not contain leading or trailing spaces/i);

fireEvent.change(await findByLabelText('Username'), {
target: { value: '€' },
});
Expand Down

0 comments on commit 6425c5d

Please sign in to comment.