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

Fix entering more than 40 chars worth of emails to dice server. #11805

Merged
merged 2 commits into from
Jul 23, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.net.URI;
import java.util.Arrays;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
Expand Down Expand Up @@ -256,9 +257,9 @@ private void checkFieldsAndNotify() {

public boolean areFieldsValid() {
final boolean toValid =
!toAddress.getText().isEmpty() && PlayerEmailValidation.isValid(toAddress.getText());
!toAddress.getText().isEmpty() && validateEmailAddresses(toAddress.getText());
final boolean ccValid =
!ccAddress.getText().isEmpty() && PlayerEmailValidation.isValid(ccAddress.getText());
!ccAddress.getText().isEmpty() && validateEmailAddresses(ccAddress.getText());

final boolean allValid = toValid && ccValid;
testDiceButton.setEnabled(allValid);
Expand All @@ -275,6 +276,10 @@ public boolean areFieldsValid() {
return allValid;
}

private boolean validateEmailAddresses(String addresses) {
return Arrays.stream(addresses.split("\\s+")).allMatch(PlayerEmailValidation::isValid);
}

public void applyToGameProperties(final GameProperties properties) {
properties.set(IRemoteDiceServer.GAME_NAME, gameId.getText());
properties.set(IRemoteDiceServer.EMAIL_1, toAddress.getText());
Expand Down