You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sebb AT ASF <se...@apache.org> on 2015/01/13 23:32:29 UTC
Re: svn commit: r1651525 - /commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/DomainValidator.java
This reverts back to the 1.4 code (except for the reflection part) and
fixes the test failures.
However it is not a permanent solution.
On 13 January 2015 at 22:30, <se...@apache.org> wrote:
> Author: sebb
> Date: Tue Jan 13 22:30:28 2015
> New Revision: 1651525
>
> URL: http://svn.apache.org/r1651525
> Log:
> Add temporary hack to get round IDN.toASCII bug
> It is not supposed to change ASCII input but it converts trailing ".." to "."
>
> Modified:
> commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/DomainValidator.java
>
> Modified: commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/DomainValidator.java
> URL: http://svn.apache.org/viewvc/commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/DomainValidator.java?rev=1651525&r1=1651524&r2=1651525&view=diff
> ==============================================================================
> --- commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/DomainValidator.java (original)
> +++ commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/DomainValidator.java Tue Jan 13 22:30:28 2015
> @@ -1085,6 +1085,9 @@ public class DomainValidator implements
> */
> // Needed by UrlValidator
> static String unicodeToASCII(String input) {
> + if (isOnlyASCII(input)) { // TODO temporary hack to work round IDN.toASCII bug
> + return input;
> + }
> try {
> return IDN.toASCII(input);
> } catch (IllegalArgumentException e) { // input is not valid
> @@ -1092,4 +1095,19 @@ public class DomainValidator implements
> }
> }
>
> + /*
> + * Check if input contains only ASCII
> + * Treats null as all ASCII
> + */
> + private static boolean isOnlyASCII(String input) {
> + if (input == null) {
> + return true;
> + }
> + for(int i=0; i < input.length(); i++) {
> + if (input.charAt(i) > 0x7F) {
> + return false;
> + }
> + }
> + return true;
> + }
> }
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: svn commit: r1651525 - /commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/DomainValidator.java
Posted by sebb AT ASF <se...@apache.org>.
Note: a permanent solution (I hope!) has now been implemented.
On 13 January 2015 at 22:32, sebb AT ASF <se...@apache.org> wrote:
> This reverts back to the 1.4 code (except for the reflection part) and
> fixes the test failures.
>
> However it is not a permanent solution.
>
> On 13 January 2015 at 22:30, <se...@apache.org> wrote:
>> Author: sebb
>> Date: Tue Jan 13 22:30:28 2015
>> New Revision: 1651525
>>
>> URL: http://svn.apache.org/r1651525
>> Log:
>> Add temporary hack to get round IDN.toASCII bug
>> It is not supposed to change ASCII input but it converts trailing ".." to "."
>>
>> Modified:
>> commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/DomainValidator.java
>>
>> Modified: commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/DomainValidator.java
>> URL: http://svn.apache.org/viewvc/commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/DomainValidator.java?rev=1651525&r1=1651524&r2=1651525&view=diff
>> ==============================================================================
>> --- commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/DomainValidator.java (original)
>> +++ commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/DomainValidator.java Tue Jan 13 22:30:28 2015
>> @@ -1085,6 +1085,9 @@ public class DomainValidator implements
>> */
>> // Needed by UrlValidator
>> static String unicodeToASCII(String input) {
>> + if (isOnlyASCII(input)) { // TODO temporary hack to work round IDN.toASCII bug
>> + return input;
>> + }
>> try {
>> return IDN.toASCII(input);
>> } catch (IllegalArgumentException e) { // input is not valid
>> @@ -1092,4 +1095,19 @@ public class DomainValidator implements
>> }
>> }
>>
>> + /*
>> + * Check if input contains only ASCII
>> + * Treats null as all ASCII
>> + */
>> + private static boolean isOnlyASCII(String input) {
>> + if (input == null) {
>> + return true;
>> + }
>> + for(int i=0; i < input.length(); i++) {
>> + if (input.charAt(i) > 0x7F) {
>> + return false;
>> + }
>> + }
>> + return true;
>> + }
>> }
>>
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org