commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hasan Diwan (JIRA)" <j...@apache.org>
Subject [jira] Created: (VALIDATOR-258) TODO: the tld should be checked against some sort of configurable list
Date Wed, 26 Mar 2008 23:27:27 GMT
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.3.1 Release, 1.3.0 Release, 1.2.0 Release, 1.1.4 Release, 1.1.3 Release,
1.1.2 (alpha), 1.1.1 (alpha), 1.1.0 (alpha), 1.4, Validator2, Nightly Builds
         Environment: all
            Reporter: Hasan Diwan
            Priority: Minor
             Fix For: Nightly Builds


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


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message