Ignore:
Timestamp:
2016-06-24T01:43:16+02:00 (8 years ago)
Author:
Don-vip
Message:

see #10862 - https://issues.apache.org/jira/browse/VALIDATOR-290 has been fixed, remove workaround

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/tests/InternetTags.java

    r10469 r10472  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
    6 import java.net.IDN;
    7 import java.util.regex.Pattern;
    8 
    9 import org.openstreetmap.josm.Main;
    106import org.openstreetmap.josm.data.osm.Node;
    117import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    2925    /** Error code for an invalid e-mail */
    3026    public static final int INVALID_EMAIL = 3302;
    31 
    32     private static final Pattern ASCII_PATTERN = Pattern.compile("^\\p{ASCII}+$");
    3327
    3428    /**
     
    8680     */
    8781    public TestError validateTag(OsmPrimitive p, String k, AbstractValidator validator, int code) {
    88         TestError error = doValidateTag(p, k, null, validator, code);
    89         if (error != null) {
    90             // Workaround to https://issues.apache.org/jira/browse/VALIDATOR-290
    91             // Apache Commons Validator 1.4.1-SNAPSHOT does not support yet IDN URLs
    92             // To remove if it gets fixed on Apache side
    93             String v = p.get(k);
    94             if (!ASCII_PATTERN.matcher(v).matches()) {
    95                 try {
    96                     String protocol = "";
    97                     if (v.contains("://")) {
    98                         protocol = v.substring(0, v.indexOf("://")+3);
    99                     }
    100                     String domain = !protocol.isEmpty() ? v.substring(protocol.length(), v.length()) : v;
    101                     String ending = "";
    102                     if (domain.contains("/")) {
    103                         int idx = domain.indexOf('/');
    104                         ending = domain.substring(idx, domain.length());
    105                         domain = domain.substring(0, idx);
    106                     }
    107                     // Try to apply ToASCII algorithm
    108                     error = doValidateTag(p, k, protocol+IDN.toASCII(domain)+ending, validator, code);
    109                 } catch (IllegalArgumentException e) {
    110                     Main.trace(e);
    111                     error.setMessage(error.getMessage() +
    112                             tr(" URL cannot be converted to ASCII: {0}", e.getMessage()));
    113                 }
    114             }
    115         }
    116         return error;
     82        return doValidateTag(p, k, null, validator, code);
    11783    }
    11884
Note: See TracChangeset for help on using the changeset viewer.