You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "JZ (JIRA)" <ji...@apache.org> on 2011/02/24 18:06:38 UTC

[jira] Commented: (VALIDATOR-276) isValidURL call returns false for file scheme/protocol when URL is correct

    [ https://issues.apache.org/jira/browse/VALIDATOR-276?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12998936#comment-12998936 ] 

JZ commented on VALIDATOR-276:
------------------------------

Even creating the UrlValidator as new UrlValidator( new String[]{"file"}, UrlValidator.ALLOW_2_SLASHES) does not allow URI using the file scheme to be validated property.

Generally, the above test cases fail on the Authority.  

The validator requires an Authority (which it considers the start of the path name in at least some of the cases, empty in others) whereas RFC-2396 states that it's optional for some schemes (of which "file" would be one).

> isValidURL call returns false for file scheme/protocol when URL is correct
> --------------------------------------------------------------------------
>
>                 Key: VALIDATOR-276
>                 URL: https://issues.apache.org/jira/browse/VALIDATOR-276
>             Project: Commons Validator
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 1.3.1 Release
>         Environment: Linux prometheus 2.6.26-1-amd64 #1 SMP Fri Mar 13 17:46:45 UTC 2009 x86_64 GNU/Linux, Debian sid
>            Reporter: atc
>            Priority: Critical
>         Attachments: URLTest.java
>
>
> Validate a URL using the file scheme/protocol for a file on a local Linux filesystem returns false. An extensive set of tests can be found here: [^URLTest.java].
> The following code snippet is a quick proof-of-concept:
> {noformat}
> import org.apache.commons.validator.UrlValidator;
> class URLTest {
> 	public static void main(String[] args) {
> 		String url = "file:///etc/hosts";
> 		UrlValidator urlValidator = new UrlValidator(new String[] {"http", "https", "ftp", "gopher", "file"});
> 		boolean result = urlValidator.isValid(url);
> 		System.out.println(String.format("URL '%s' is valid: %s", url, result));
> 	}
> }
> {noformat}
> This issue occurs whether the scheme String[] constructor or the ALLOW_ALL_SCHEMES equivalent is used.

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira