Skip to content

Commit 9b71286

Browse files
committed
Fixed regex bug in Safari (#89399)
* Fixed regex bug in Safari * Added extra unit test
1 parent 81438b2 commit 9b71286

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

x-pack/plugins/security/common/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const NEXT_URL_QUERY_STRING_PARAMETER = 'next';
2929
* - Must contain only letters, numbers, spaces, punctuation and printable symbols.
3030
* - Must not contain leading or trailing spaces.
3131
*/
32-
export const NAME_REGEX = /^(?! )[a-zA-Z0-9 !"#$%&'()*+,\-./\\:;<=>?@\[\]^_`{|}~]+(?<! )$/;
32+
export const NAME_REGEX = /^(?! )[a-zA-Z0-9 !"#$%&'()*+,\-./\\:;<=>?@\[\]^_`{|}~]*[a-zA-Z0-9!"#$%&'()*+,\-./\\:;<=>?@\[\]^_`{|}~]$/;
3333

3434
/**
3535
* Maximum length of usernames and role names.

x-pack/plugins/security/public/management/users/edit_user/create_user_page.test.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ describe('CreateUserPage', () => {
8888

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

91+
fireEvent.change(await findByLabelText('Username'), {
92+
target: { value: 'username_with_trailing_space ' },
93+
});
94+
95+
await findAllByText(/Username must not contain leading or trailing spaces/i);
96+
9197
fireEvent.change(await findByLabelText('Username'), {
9298
target: { value: '€' },
9399
});

0 commit comments

Comments
 (0)