From 17542ce7460edec89d6bfb81642b5ba753a5550d Mon Sep 17 00:00:00 2001 From: asvitkine Date: Sun, 23 Jul 2023 10:16:41 -0400 Subject: [PATCH] Fix entering more than 40 chars worth of emails to dice server. (#11805) * Fix entering more than 40 chars worth of emails to dice server. * Formatting. --- .../startup/ui/posted/game/DiceServerEditor.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/game-app/game-core/src/main/java/games/strategy/engine/framework/startup/ui/posted/game/DiceServerEditor.java b/game-app/game-core/src/main/java/games/strategy/engine/framework/startup/ui/posted/game/DiceServerEditor.java index f2193c38a94..63c41b04a57 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/framework/startup/ui/posted/game/DiceServerEditor.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/framework/startup/ui/posted/game/DiceServerEditor.java @@ -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; @@ -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); @@ -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());