This is an automated email from the ASF dual-hosted git repository. garydgregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-validator.git
commit a2ade8a0c934db23d670dc5bb26a1b92e1a52b2f Author: Gary Gregory <[email protected]> AuthorDate: Fri Jul 31 20:29:51 2026 -0400 Sort members --- .../validator/routines/DomainValidator.java | 26 +++++++++++----------- .../validator/routines/CurrencyValidatorTest.java | 6 ++--- .../validator/routines/DomainValidatorTest.java | 18 +++++++-------- .../validator/routines/PercentValidatorTest.java | 6 ++--- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/main/java/org/apache/commons/validator/routines/DomainValidator.java b/src/main/java/org/apache/commons/validator/routines/DomainValidator.java index 56061fcb..c3566de0 100644 --- a/src/main/java/org/apache/commons/validator/routines/DomainValidator.java +++ b/src/main/java/org/apache/commons/validator/routines/DomainValidator.java @@ -1951,6 +1951,19 @@ public class DomainValidator implements Serializable { return ch == '.' || ch == '\u3002' || ch == '\uFF0E' || ch == '\uFF61'; } + /* + * Tests whether the code point is one that IDNA nameprep (RFC 3454 Table B.1, "commonly mapped to + * nothing") deletes but that is not a Unicode FORMAT character, so the FORMAT check in + * unicodeToASCII does not catch it: the combining grapheme joiner, the Mongolian TODO soft hyphen + * and free variation selectors, and the variation selectors. + */ + private static boolean isNameprepMappedToNothing(final int codePoint) { + return codePoint == '\u034F' // COMBINING GRAPHEME JOINER + || codePoint == '\u1806' // MONGOLIAN TODO SOFT HYPHEN + || codePoint >= '\u180B' && codePoint <= '\u180D' // MONGOLIAN FREE VARIATION SELECTOR ONE..THREE + || codePoint >= '\uFE00' && codePoint <= '\uFE0F'; // VARIATION SELECTOR-1..16 + } + /* * Tests whether input contains only ASCII. Treats null as all ASCII. */ @@ -1966,19 +1979,6 @@ public class DomainValidator implements Serializable { return true; } - /* - * Tests whether the code point is one that IDNA nameprep (RFC 3454 Table B.1, "commonly mapped to - * nothing") deletes but that is not a Unicode FORMAT character, so the FORMAT check in - * unicodeToASCII does not catch it: the combining grapheme joiner, the Mongolian TODO soft hyphen - * and free variation selectors, and the variation selectors. - */ - private static boolean isNameprepMappedToNothing(final int codePoint) { - return codePoint == '\u034F' // COMBINING GRAPHEME JOINER - || codePoint == '\u1806' // MONGOLIAN TODO SOFT HYPHEN - || codePoint >= '\u180B' && codePoint <= '\u180D' // MONGOLIAN FREE VARIATION SELECTOR ONE..THREE - || codePoint >= '\uFE00' && codePoint <= '\uFE0F'; // VARIATION SELECTOR-1..16 - } - /** * Converts potentially Unicode input to punycode. If conversion fails, returns the original input. * diff --git a/src/test/java/org/apache/commons/validator/routines/CurrencyValidatorTest.java b/src/test/java/org/apache/commons/validator/routines/CurrencyValidatorTest.java index b070eb82..b4de8fe6 100644 --- a/src/test/java/org/apache/commons/validator/routines/CurrencyValidatorTest.java +++ b/src/test/java/org/apache/commons/validator/routines/CurrencyValidatorTest.java @@ -46,9 +46,6 @@ class CurrencyValidatorTest { /** The character locales such as de-DE use between the number and a trailing currency symbol. */ private static final char NON_BREAKING_SPACE = '\u00A0'; - private String usDollar; - private String ukPound; - /** * Locales whose currency format suffixes the symbol behind a space separator, covering different concrete symbols (€ and kr). * @@ -57,6 +54,9 @@ class CurrencyValidatorTest { static Stream<Locale> suffixSymbolLocales() { return Stream.of(Locale.GERMANY, Locale.FRANCE, Locale.forLanguageTag("sv-SE")); } + private String usDollar; + + private String ukPound; @BeforeEach protected void setUp() { diff --git a/src/test/java/org/apache/commons/validator/routines/DomainValidatorTest.java b/src/test/java/org/apache/commons/validator/routines/DomainValidatorTest.java index 18aeeaa5..4d880d4d 100644 --- a/src/test/java/org/apache/commons/validator/routines/DomainValidatorTest.java +++ b/src/test/java/org/apache/commons/validator/routines/DomainValidatorTest.java @@ -471,6 +471,15 @@ public class DomainValidatorTest { assertTrue(validator.isValid("www.b\u00fccher.ch"), "b\u00fccher.ch should still validate"); } + @Test + void testIDNJava6OrLater() { + // xn--d1abbgf6aiiy.xn--p1ai http://президент.рф + assertTrue(validator.isValid("www.b\u00fccher.ch"), "b\u00fccher.ch should validate"); + assertTrue(validator.isValid("xn--d1abbgf6aiiy.xn--p1ai"), "xn--d1abbgf6aiiy.xn--p1ai should validate"); + assertTrue(validator.isValid("президент.рф"), "президент.рф should validate"); + assertFalse(validator.isValid("www.\uFFFD.ch"), "www.\uFFFD.ch FFFD should fail"); + } + @Test void testIDNMappedToNothing() { // IDN.toASCII also strips the code points that nameprep maps to nothing but that are not @@ -483,15 +492,6 @@ public class DomainValidatorTest { assertTrue(validator.isValid("www.b\u00fccher.ch"), "b\u00fccher.ch should still validate"); } - @Test - void testIDNJava6OrLater() { - // xn--d1abbgf6aiiy.xn--p1ai http://президент.рф - assertTrue(validator.isValid("www.b\u00fccher.ch"), "b\u00fccher.ch should validate"); - assertTrue(validator.isValid("xn--d1abbgf6aiiy.xn--p1ai"), "xn--d1abbgf6aiiy.xn--p1ai should validate"); - assertTrue(validator.isValid("президент.рф"), "президент.рф should validate"); - assertFalse(validator.isValid("www.\uFFFD.ch"), "www.\uFFFD.ch FFFD should fail"); - } - // Check array is sorted and is lower-case @Test void testInfrastructureTldsSortedAndLowerCase() throws Exception { diff --git a/src/test/java/org/apache/commons/validator/routines/PercentValidatorTest.java b/src/test/java/org/apache/commons/validator/routines/PercentValidatorTest.java index 2dff8066..894335fb 100644 --- a/src/test/java/org/apache/commons/validator/routines/PercentValidatorTest.java +++ b/src/test/java/org/apache/commons/validator/routines/PercentValidatorTest.java @@ -47,9 +47,6 @@ class PercentValidatorTest { /** The character locales such as fr-FR use between the number and a trailing percent symbol. */ private static final char NON_BREAKING_SPACE = '\u00A0'; - protected PercentValidator validator; - private Locale originalLocale; - /** * Locales whose percent format suffixes the symbol behind a space separator. * @@ -58,6 +55,9 @@ class PercentValidatorTest { static Stream<Locale> suffixSymbolLocales() { return Stream.of(Locale.FRANCE, Locale.GERMANY); } + protected PercentValidator validator; + + private Locale originalLocale; @BeforeEach protected void setUp() {
