You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2026/07/17 00:30:52 UTC

(commons-validator) branch master updated (56cb05a7 -> f38422b2)

This is an automated email from the ASF dual-hosted git repository.

garydgregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-validator.git


    from 56cb05a7 Merge pull request #425 from sahvx655-wq/date-strict-trailing-chars
     new d7c8a77c Reject trailing characters in strict date validation (#425).
     new f38422b2 Sort members.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/changes/changes.xml                            |  2 +-
 .../validator/GenericTypeValidatorTest.java        | 30 +++++++++++-----------
 .../commons/validator/GenericValidatorTest.java    | 16 ++++++------
 .../validator/routines/UrlValidatorTest.java       | 26 +++++++++----------
 4 files changed, 37 insertions(+), 37 deletions(-)


(commons-validator) 02/02: Sort members.

Posted by gg...@apache.org.
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 f38422b29ec808f5d14cfc818ae568f77bd1eba9
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Jul 16 20:30:47 2026 -0400

    Sort members.
---
 .../validator/GenericTypeValidatorTest.java        | 30 +++++++++++-----------
 .../commons/validator/GenericValidatorTest.java    | 16 ++++++------
 .../validator/routines/UrlValidatorTest.java       | 26 +++++++++----------
 3 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/src/test/java/org/apache/commons/validator/GenericTypeValidatorTest.java b/src/test/java/org/apache/commons/validator/GenericTypeValidatorTest.java
index 99329278..752ee3a6 100644
--- a/src/test/java/org/apache/commons/validator/GenericTypeValidatorTest.java
+++ b/src/test/java/org/apache/commons/validator/GenericTypeValidatorTest.java
@@ -100,6 +100,21 @@ class GenericTypeValidatorTest extends AbstractCommonTest {
     protected void tearDown() {
     }
 
+    /**
+     * Tests that strict {@link GenericTypeValidator#formatDate(String, String, boolean)} rejects a value with trailing characters instead of parsing only its
+     * leading portion.
+     */
+    @Test
+    void testFormatDateStrict() {
+        assertNotNull(GenericTypeValidator.formatDate("11/11/1999", "MM/dd/yyyy", true));
+        // The trailing 'f' used to be dropped, leaving the year parsed as 199 and the value reported as valid.
+        assertNull(GenericTypeValidator.formatDate("11/11/199f", "MM/dd/yyyy", true));
+        // An abbreviated field is still rejected in strict mode.
+        assertNull(GenericTypeValidator.formatDate("2/12/1999", "MM/dd/yyyy", true));
+        // Non-strict parsing stays lenient about the pattern length.
+        assertNotNull(GenericTypeValidator.formatDate("2/12/1999", "MM/dd/yyyy", false));
+    }
+
     /**
      * Tests the fr locale.
      */
@@ -133,21 +148,6 @@ class GenericTypeValidatorTest extends AbstractCommonTest {
         assertNull(GenericTypeValidator.formatLong("123x", Locale.US));
     }
 
-    /**
-     * Tests that strict {@link GenericTypeValidator#formatDate(String, String, boolean)} rejects a value with trailing characters instead of parsing only its
-     * leading portion.
-     */
-    @Test
-    void testFormatDateStrict() {
-        assertNotNull(GenericTypeValidator.formatDate("11/11/1999", "MM/dd/yyyy", true));
-        // The trailing 'f' used to be dropped, leaving the year parsed as 199 and the value reported as valid.
-        assertNull(GenericTypeValidator.formatDate("11/11/199f", "MM/dd/yyyy", true));
-        // An abbreviated field is still rejected in strict mode.
-        assertNull(GenericTypeValidator.formatDate("2/12/1999", "MM/dd/yyyy", true));
-        // Non-strict parsing stays lenient about the pattern length.
-        assertNotNull(GenericTypeValidator.formatDate("2/12/1999", "MM/dd/yyyy", false));
-    }
-
     /**
      * Tests the byte validation.
      */
diff --git a/src/test/java/org/apache/commons/validator/GenericValidatorTest.java b/src/test/java/org/apache/commons/validator/GenericValidatorTest.java
index 36b81fe2..88a87310 100644
--- a/src/test/java/org/apache/commons/validator/GenericValidatorTest.java
+++ b/src/test/java/org/apache/commons/validator/GenericValidatorTest.java
@@ -26,6 +26,14 @@ import org.junit.jupiter.api.Test;
  */
 class GenericValidatorTest {
 
+    @Test
+    void testIsDate() {
+        assertTrue(GenericValidator.isDate("11/11/1999", "MM/dd/yyyy", true), "valid strict date");
+        // Strict validation used to accept a value with a trailing character by parsing only its leading portion.
+        assertFalse(GenericValidator.isDate("11/11/199f", "MM/dd/yyyy", true), "trailing character");
+        assertFalse(GenericValidator.isDate("2/12/1999", "MM/dd/yyyy", true), "abbreviated month");
+    }
+
     @Test
     void testMaxLength() {
 
@@ -48,14 +56,6 @@ class GenericValidatorTest {
         assertTrue(GenericValidator.maxLength("12345\n\r", 7, 2), "Max=7 End=2");
     }
 
-    @Test
-    void testIsDate() {
-        assertTrue(GenericValidator.isDate("11/11/1999", "MM/dd/yyyy", true), "valid strict date");
-        // Strict validation used to accept a value with a trailing character by parsing only its leading portion.
-        assertFalse(GenericValidator.isDate("11/11/199f", "MM/dd/yyyy", true), "trailing character");
-        assertFalse(GenericValidator.isDate("2/12/1999", "MM/dd/yyyy", true), "abbreviated month");
-    }
-
     @Test
     void testMinLength() {
 
diff --git a/src/test/java/org/apache/commons/validator/routines/UrlValidatorTest.java b/src/test/java/org/apache/commons/validator/routines/UrlValidatorTest.java
index dcb05da7..4de098a8 100644
--- a/src/test/java/org/apache/commons/validator/routines/UrlValidatorTest.java
+++ b/src/test/java/org/apache/commons/validator/routines/UrlValidatorTest.java
@@ -184,19 +184,6 @@ public class UrlValidatorTest {
         assertFalse(urlValidator.isValidAuthority("[::1]:65536"));
     }
 
-    @Test
-    void testIpv6Userinfo() {
-        final UrlValidator urlValidator = new UrlValidator();
-        // userinfo is allowed before a bracketed IPv6 host, not only before a hostname/IPv4 host
-        assertTrue(urlValidator.isValid("http://user@[::1]/"));
-        assertTrue(urlValidator.isValid("http://user:pass@[2001:db8::1]:8080/index.html"));
-        assertTrue(urlValidator.isValidAuthority("user@[::1]"));
-        assertTrue(urlValidator.isValidAuthority("user:pass@[::1]:65535"));
-        // the host and port checks still apply through the userinfo path
-        assertFalse(urlValidator.isValid("http://user@[::ffff:129.144.52.999]/"));
-        assertFalse(urlValidator.isValidAuthority("user@[::1]:65536"));
-    }
-
     @ParameterizedTest
     // @formatter:off
     @ValueSource(strings = {
@@ -240,6 +227,19 @@ public class UrlValidatorTest {
         assertTrue(urlValidator.isValidAuthority(host + ":80"));
     }
 
+    @Test
+    void testIpv6Userinfo() {
+        final UrlValidator urlValidator = new UrlValidator();
+        // userinfo is allowed before a bracketed IPv6 host, not only before a hostname/IPv4 host
+        assertTrue(urlValidator.isValid("http://user@[::1]/"));
+        assertTrue(urlValidator.isValid("http://user:pass@[2001:db8::1]:8080/index.html"));
+        assertTrue(urlValidator.isValidAuthority("user@[::1]"));
+        assertTrue(urlValidator.isValidAuthority("user:pass@[::1]:65535"));
+        // the host and port checks still apply through the userinfo path
+        assertFalse(urlValidator.isValid("http://user@[::ffff:129.144.52.999]/"));
+        assertFalse(urlValidator.isValidAuthority("user@[::1]:65536"));
+    }
+
     @Test
     void testIsValid() {
         testIsValid(testUrlParts, UrlValidator.ALLOW_ALL_SCHEMES);


(commons-validator) 01/02: Reject trailing characters in strict date validation (#425).

Posted by gg...@apache.org.
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 d7c8a77c8313139e6c7c662666009ab486931dfd
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Jul 16 20:30:29 2026 -0400

    Reject trailing characters in strict date validation (#425).
---
 src/changes/changes.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index fa55de22..06ed61a6 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -104,7 +104,7 @@ The <action> type attribute can be add,update,fix,remove.
     <action type="fix" dev="ggregory" due-to="sahvx655-wq, Gary Gregory">Handle Float operand in AbstractNumberValidator.toBigDecimal (#419).</action>
     <action type="fix" dev="ggregory" due-to="sahvx655-wq, Gary Gregory">Reject format code points in DomainValidator.unicodeToASCII (#420).</action>
     <action type="fix" dev="ggregory" due-to="sahvx655-wq, Gary Gregory">Allow userinfo before a bracketed IPv6 host in isValidAuthority (#421).</action>
-    <action type="fix" dev="ggregory" due-to="sahvx655-wq, Gary Gregory">Reject control characters in EmailValidator local part (#422).</action>
+    <action type="fix" dev="ggregory" due-to="sahvx655-wq, Gary Gregory">Reject trailing characters in strict date validation (#425).</action>
     <!-- ADD -->
     <action type="add" dev="ggregory" due-to="Gary Gregory">Add and use CheckDigitException.CheckDigitException(String, Object...) (#389).</action>
     <action type="add" dev="ggregory" due-to="Gary Gregory">Add and use ValidatorException.ValidatorException(Throwable). Call sites that previously called new ValidatorException(Throwable#getMessage()) now preserve that exception (#390).</action>