[
https://issues.apache.org/jira/browse/VALIDATOR-258?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Hasan Diwan updated VALIDATOR-258:
----------------------------------
Description: Add support for a textfile containing TLDs. If the file
is not found, use the existing code (i.e. return true). (was: Index:
/Users/hdiwan/Developer/Validator/src/main/java/org/apache/commons/validator/EmailValidator.java
===================================================================
---
/Users/hdiwan/Developer/Validator/src/main/java/org/apache/commons/validator/EmailValidator.java
(revision 641610)
+++
/Users/hdiwan/Developer/Validator/src/main/java/org/apache/commons/validator/EmailValidator.java
(working copy)
@@ -19,6 +19,12 @@
import org.apache.commons.validator.routines.InetAddressValidator;
import org.apache.oro.text.perl.Perl5Util;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.HashSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -195,8 +201,21 @@
return false;
}
- // TODO: the tld should be checked against some sort of configurable
- // list
+ HashSet tldSet = new HashSet();
+ BufferedReader tlds = null;
+ try {
+ tlds = new BufferedReader(new FileReader(" tlds.list"));
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ }
+ String line = null;
+ try {
+ while ((line = tlds.readLine()) != null) {
+ tldSet.add(line);
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
String tld = domainSegment[len - 1];
if (tld.length() > 1) {
Perl5Util matchTldPat = new Perl5Util();
@@ -207,7 +226,7 @@
return false;
}
- return true;
+ return tldSet.contains(tld);
}
/**
* Recursively remove comments, and replace with a single space. The
simpler
)
Remaining Estimate: 0.02h
Original Estimate: 0.02h
> TODO: the tld should be checked against some sort of configurable list
> ----------------------------------------------------------------------
>
> Key: VALIDATOR-258
> URL: https://issues.apache.org/jira/browse/VALIDATOR-258
> Project: Commons Validator
> Issue Type: Task
> Components: Framework
> Affects Versions: 1.1.0 (alpha), 1.1.1 (alpha), 1.1.2 (alpha), 1.1.3
> Release, 1.1.4 Release, 1.2.0 Release, 1.3.0 Release, 1.3.1 Release, 1.4,
> Validator2, Nightly Builds
> Environment: all
> Reporter: Hasan Diwan
> Priority: Minor
> Fix For: Nightly Builds
>
> Original Estimate: 0.02h
> Remaining Estimate: 0.02h
>
> Add support for a textfile containing TLDs. If the file is not found, use the
> existing code (i.e. return true).
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.