commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1742006 - in /commons/proper/validator/trunk/src: changes/changes.xml main/java/org/apache/commons/validator/routines/UrlValidator.java test/java/org/apache/commons/validator/routines/UrlValidatorTest.java
Date Mon, 02 May 2016 16:45:17 GMT
Author: sebb
Date: Mon May  2 16:45:16 2016
New Revision: 1742006

URL: http://svn.apache.org/viewvc?rev=1742006&view=rev
Log:
VALIDATOR-391 UrlValidator.isValid throws exception for FILEURLs
    Fixed code so it handles URLs with no authority field

Modified:
    commons/proper/validator/trunk/src/changes/changes.xml
    commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/UrlValidator.java
    commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/UrlValidatorTest.java

Modified: commons/proper/validator/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/validator/trunk/src/changes/changes.xml?rev=1742006&r1=1742005&r2=1742006&view=diff
==============================================================================
--- commons/proper/validator/trunk/src/changes/changes.xml (original)
+++ commons/proper/validator/trunk/src/changes/changes.xml Mon May  2 16:45:16 2016
@@ -64,6 +64,13 @@ The <action> type attribute can be add,u
      -->
 
   <body>
+  <release version="1.5.2" date="TBA" description="
+  ">
+    <action issue="VALIDATOR-391" type="fix" dev="sebb" due-to="Mark E. Scott, Jr. &amp;
Jason Loomis">
+    UrlValidator.isValid throws exception for FILEURLs
+    Fixed code so it handles URLs with no authority field
+    </action>
+  </release>
   <release version="1.5.1" date="2016-04-30" description="
 This is a maintenance release.
 

Modified: commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/UrlValidator.java
URL: http://svn.apache.org/viewvc/commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/UrlValidator.java?rev=1742006&r1=1742005&r2=1742006&view=diff
==============================================================================
--- commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/UrlValidator.java
(original)
+++ commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/UrlValidator.java
Mon May  2 16:45:16 2016
@@ -312,7 +312,7 @@ public class UrlValidator implements Ser
 
         String authority = urlMatcher.group(PARSE_URL_AUTHORITY);
         if ("file".equals(scheme)) {// Special case - file: allows an empty authority
-            if (!"".equals(authority)) {
+            if (authority != null) {
                 if (authority.contains(":")) { // but cannot allow trailing :
                     return false;
                 }

Modified: commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/UrlValidatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/UrlValidatorTest.java?rev=1742006&r1=1742005&r2=1742006&view=diff
==============================================================================
--- commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/UrlValidatorTest.java
(original)
+++ commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/UrlValidatorTest.java
Mon May  2 16:45:16 2016
@@ -275,6 +275,17 @@ protected void setUp() {
               validator.isValid("file://C:\\some.file"));
     }
 
+    public void testValidator391OK() {
+        String[] schemes = {"file"};
+        UrlValidator urlValidator = new UrlValidator(schemes);
+        urlValidator.isValid("file:///C:/path/to/dir/");
+    }
+    
+    public void testValidator391FAILS() {
+        String[] schemes = {"file"};
+        UrlValidator urlValidator = new UrlValidator(schemes);
+        urlValidator.isValid("file:/C:/path/to/dir/");
+    }
     
     public void testValidator309() {
         UrlValidator urlValidator = new UrlValidator();



Mime
View raw message