mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-22 22:45:21 +01:00
Fix address validation for whitespace after comma
Typical comma separated values have a space after each comma in order to make the list more human-readable. In some areas of bisq, comma separated lists are generated this way (see #4203), but the validation of comma separated addresses was not accepting spaces after commas. This change to the regex allows optional whitespace after comma separators. A new test has been added to validate the scenario of whitespace after comma. Fixes #4203
This commit is contained in:
parent
246d5ee37a
commit
f4064dfcfb
2 changed files with 2 additions and 1 deletions
|
@ -1152,7 +1152,7 @@ public class GUIUtil {
|
|||
")"; // (IPv4-Embedded IPv6 Address)
|
||||
ipv6RegexPattern = String.format("(?:%1$s)|(?:\\[%1$s\\]\\:%2$s)", ipv6RegexPattern, portRegexPattern);
|
||||
String fqdnRegexPattern = String.format("(((?!-)[a-zA-Z0-9-]{1,63}(?<!-)\\.)+(?!onion)[a-zA-Z]{2,63}(?:\\:%1$s)?)", portRegexPattern);
|
||||
regexValidator.setPattern(String.format("^(?:(?:(?:%1$s)|(?:%2$s)|(?:%3$s)|(?:%4$s)),)*(?:(?:%1$s)|(?:%2$s)|(?:%3$s)|(?:%4$s))*$",
|
||||
regexValidator.setPattern(String.format("^(?:(?:(?:%1$s)|(?:%2$s)|(?:%3$s)|(?:%4$s)),\\s*)*(?:(?:%1$s)|(?:%2$s)|(?:%3$s)|(?:%4$s))*$",
|
||||
onionV2RegexPattern, ipv4RegexPattern, ipv6RegexPattern, fqdnRegexPattern));
|
||||
return regexValidator;
|
||||
}
|
||||
|
|
|
@ -129,6 +129,7 @@ public class GUIUtilTest {
|
|||
// onion V2 addresses
|
||||
assertTrue(regexValidator.validate("abcdefghij234567.onion").isValid);
|
||||
assertTrue(regexValidator.validate("abcdefghijklmnop.onion,abcdefghijklmnop.onion").isValid);
|
||||
assertTrue(regexValidator.validate("abcdefghijklmnop.onion, abcdefghijklmnop.onion").isValid);
|
||||
assertTrue(regexValidator.validate("qrstuvwxyzABCDEF.onion,qrstuvwxyzABCDEF.onion,aaaaaaaaaaaaaaaa.onion").isValid);
|
||||
assertTrue(regexValidator.validate("GHIJKLMNOPQRSTUV.onion:9999").isValid);
|
||||
assertTrue(regexValidator.validate("WXYZ234567abcdef.onion,GHIJKLMNOPQRSTUV.onion:9999").isValid);
|
||||
|
|
Loading…
Add table
Reference in a new issue