This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-validator.git
The following commit(s) were added to refs/heads/master by this push:
new b69d9e5a Check that cc tlds are present and in correct list
b69d9e5a is described below
commit b69d9e5a761097f6f2f29acf895e8016443860f5
Author: Sebb <[email protected]>
AuthorDate: Tue Jun 23 15:04:15 2026 +0100
Check that cc tlds are present and in correct list
See https://github.com/apache/commons-validator/pull/409
---
src/changes/changes.xml | 1 +
.../validator/routines/DomainValidatorTest.java | 27 +++++++++++++++-------
2 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index f19a990d..1a8b421d 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -90,6 +90,7 @@ The <action> type attribute can be add,update,fix,remove.
<action type="fix" dev="ggregory" due-to="sahvx655-wq, Gary
Gregory">Accept IPv4-embedded IPv6 addresses in UrlValidator (#405).</action>
<action type="fix" dev="ggregory" due-to="sahvx655-wq, Gary
Gregory">Preserve exact value in BigDecimal and BigInteger validate
(#406).</action>
<action type="fix" dev="ggregory" due-to="sahvx655-wq, Gary
Gregory">Preserve fractional bound in BigIntegerValidator range checks
(#407).</action>
+ <action type="fix" dev="sebb" due-to="sahvx655-wq">DomainValidatorTest:
ensure CC is in correct list (#409).</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>
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 431fce1b..410e008c 100644
---
a/src/test/java/org/apache/commons/validator/routines/DomainValidatorTest.java
+++
b/src/test/java/org/apache/commons/validator/routines/DomainValidatorTest.java
@@ -301,6 +301,7 @@ public class DomainValidatorTest {
final Map<String, String[]> htmlInfo = getHtmlInfo(htmlFile);
final Map<String, String> missingTLD = new TreeMap<>(); // stores
entry and comments as String[]
final Map<String, String> missingCC = new TreeMap<>();
+ int errorsDetected = 0;
while ((line = br.readLine()) != null) {
if (!line.startsWith("#")) {
final String unicodeTld; // only different from asciiTld if
that was punycode
@@ -310,11 +311,22 @@ public class DomainValidatorTest {
} else {
unicodeTld = asciiTld;
}
- if (!dv.isValidTld(asciiTld)) {
- final String[] info = htmlInfo.get(asciiTld);
- if (info != null) {
- final String type = info[0];
- final String comment = info[1];
+ final String[] info = htmlInfo.get(asciiTld);
+ if (info != null) {
+ final String type = info[0];
+ final String comment = info[1];
+ if (dv.isValidTld(asciiTld)) { // we have an entry; is it
in correct list?
+ if ("country-code".equals(type)) {
+ if (!dv.isValidCountryCodeTld(asciiTld)) {// wrong
list
+ missingCC.put(asciiTld, unicodeTld + " " +
comment);
+ if (generateUnicodeTlds) {
+ missingCC.put(unicodeTld, asciiTld + " " +
comment);
+ }
+ System.out.println("GENERIC list contains
unexpected value: " + asciiTld);
+ errorsDetected ++;
+ }
+ }
+ } else { // missing entry, add it to correct list
if ("country-code".equals(type)) { // Which list to
use?
missingCC.put(asciiTld, unicodeTld + " " +
comment);
if (generateUnicodeTlds) {
@@ -326,9 +338,9 @@ public class DomainValidatorTest {
missingTLD.put(unicodeTld, asciiTld + " " +
comment);
}
}
- } else {
- System.err.println("Expected to find HTML info for " +
asciiTld);
}
+ } else {
+ System.err.println("Expected to find HTML info for " +
asciiTld);
}
ianaTlds.add(asciiTld);
// Don't merge these conditions; generateUnicodeTlds is final
so needs to be separate to avoid a warning
@@ -341,7 +353,6 @@ public class DomainValidatorTest {
}
}
br.close();
- int errorsDetected = 0;
// List html entries not in TLD text list
for (final String key : new TreeMap<>(htmlInfo).keySet()) {
if (!ianaTlds.contains(key)) {