Skip to content

Commit

Permalink
fix: add character restrictions to password in createUser and changeP…
Browse files Browse the repository at this point in the history
…assword dialogs [BISERVER-15243]
  • Loading branch information
joana-fb authored and smmribeiro committed Feb 24, 2025
1 parent 2a057c5 commit 74290a6
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public class UserDialog extends GwtDialog {
private PasswordTextBox reTypePasswordTextBox;
private Button acceptBtn = new Button( Messages.getString( "ok" ) );
private Button cancelBtn = new Button( Messages.getString( "cancel" ) );
private static final String USER_ALLOWED_CHARS = "^[a-zA-Z0-9_.,;<>|!@#$%^&*()\\[\\]]+$";
private static final RegExp USER_ALLOWED_CHARS_REGEXP = RegExp.compile( USER_ALLOWED_CHARS );
private static final String USER_ALLOWED_CHARS_LIST = "a-z A-Z 0-9 _ . , ; < > | ! @ # $ % ^ & * ( ) [ ]";
private static final String ALLOWED_CHARS = "^[a-zA-Z0-9_.,:;<>|!@#$%^&*()\\[\\]]+$";
private static final RegExp ALLOWED_CHARS_REGEXP = RegExp.compile( ALLOWED_CHARS );
private static final String ALLOWED_CHARS_LIST = "a-z A-Z 0-9 _ . , : ; < > | ! @ # $ % ^ & * ( ) [ ]";
Expand Down Expand Up @@ -154,7 +157,7 @@ public void onResponseReceived( Request request, Response response ) {
String reservedCharacters = response.getText();

if ( !isValidUsername( userName, reservedCharacters )) {
showErrorMessage( userName, ALLOWED_CHARS_LIST );
showErrorMessage( userName, USER_ALLOWED_CHARS_LIST );
return;
}

Expand All @@ -172,7 +175,7 @@ private boolean isValidPassword( String password ) {
}

private boolean isValidUsername( String userName, String reservedCharacters ) {
return isValidName( userName, reservedCharacters ) && ALLOWED_CHARS_REGEXP.test( userName );
return isValidName( userName, reservedCharacters ) && USER_ALLOWED_CHARS_REGEXP.test( userName );
}

@Override
Expand Down

0 comments on commit 74290a6

Please sign in to comment.