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

Sebb commented on VALIDATOR-406:
--------------------------------

I can confirm the IOOBE, but this seems more like a bug in Java than in 
Validator.

If the function java.net.IDN.toASCII cannot handle the input it should throw 
e.g. InvalidArgumentException.
There's no indication in the Javadoc that such input is not allowed, nor is 
IOOBE documented as a 'normal' exception.

Whilst Validator could catch it and treat it the same as IAE, I'm not sure it's 
a good idea to do so as it hides the bug.

> java.lang.IndexOutOfBoundsException in UrlValidator.isValid()
> -------------------------------------------------------------
>
>                 Key: VALIDATOR-406
>                 URL: https://issues.apache.org/jira/browse/VALIDATOR-406
>             Project: Commons Validator
>          Issue Type: Bug
>          Components: Routines
>    Affects Versions: 1.5.1
>            Reporter: Gerard Bouchar
>
> String[] schemes = {"http","https"};
> UrlValidator validator = new UrlValidator(schemes);
> validator.isValid("http://aaaaa aaaaa aaaaa aaaaa aaa’aa aaaaa aaaaa aaaaa 
> aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa 
> aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa 
> aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa");
> causes : 
> Exception in thread "main" java.lang.IndexOutOfBoundsException
>       at sun.net.idn.Punycode.encode(Punycode.java:188)
>       at java.net.IDN.toASCIIInternal(IDN.java:320)
>       at java.net.IDN.toASCII(IDN.java:122)
>       at java.net.IDN.toASCII(IDN.java:151)
>       at 
> org.apache.commons.validator.routines.DomainValidator.unicodeToASCII(DomainValidator.java:1764)
>       at 
> org.apache.commons.validator.routines.UrlValidator.isValidAuthority(UrlValidator.java:389)
>       at 
> org.apache.commons.validator.routines.UrlValidator.isValid(UrlValidator.java:323)
>       at testBloom.TestBloom.main(TestBloom.java:153)



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to