RTEditor/src/main/java/com/onegravity/rteditor/utils/validator/UrlValidator.java
protected boolean isValidAuthority(String authority) {
        if (authority == null) {
            return false;
        }

        // check manual authority validation if specified
        if (authorityValidator != null && authorityValidator.isValid(authority)) {
            return true;
        }
        // convert to ASCII if possible
        final String authorityASCII = DomainValidator.unicodeToASCII(authority);

        Matcher authorityMatcher = AUTHORITY_PATTERN.matcher(authorityASCII);
        if (!authorityMatcher.matches()) {
            return false;
        }

        String hostLocation = authorityMatcher.group(PARSE_AUTHORITY_HOST_IP);
        // check if authority is hostname or IP address:
        // try a hostname first since that's much more likely
        DomainValidator domainValidator = DomainValidator.getInstance(isOn(ALLOW_LOCAL_URLS));
        if (!domainValidator.isValid(hostLocation)) {
            // try an IP address
            InetAddressValidator inetAddressValidator =
                InetAddressValidator.getInstance();
            if (!inetAddressValidator.isValid(hostLocation)) {
                // isn't either one, so the URL is invalid
                return false;
            }
        }

        String port = authorityMatcher.group(PARSE_AUTHORITY_PORT);
        if (port != null && !PORT_PATTERN.matcher(port).matches()) {
            return false;
        }

        String extra = authorityMatcher.group(PARSE_AUTHORITY_EXTRA);
        if (extra != null && extra.trim().length() > 0){
            return false;
        }

        return true;
    }
protected boolean isValidAuthority(String authority) {
        if (authority == null) {
            return false;
        }

        // check manual authority validation if specified
        if (authorityValidator != null && authorityValidator.isValid(authority)) {
            return true;
        }
        // convert to ASCII if possible
        final String authorityASCII = DomainValidator.unicodeToASCII(authority);

        Matcher authorityMatcher = AUTHORITY_PATTERN.matcher(authorityASCII);
        if (!authorityMatcher.matches()) {
            return false;
        }

        String hostLocation = authorityMatcher.group(PARSE_AUTHORITY_HOST_IP);
        // check if authority is hostname or IP address:
        // try a hostname first since that's much more likely
        DomainValidator domainValidator = DomainValidator.getInstance(isOn(ALLOW_LOCAL_URLS));
        if (!domainValidator.isValid(hostLocation)) {
            // try an IP address
            InetAddressValidator inetAddressValidator =
                InetAddressValidator.getInstance();
            if (!inetAddressValidator.isValid(hostLocation)) {
                // isn't either one, so the URL is invalid
                return false;
            }
        }

        String port = authorityMatcher.group(PARSE_AUTHORITY_PORT);
        if (port != null && !PORT_PATTERN.matcher(port).matches()) {
            return false;
        }

        String extra = authorityMatcher.group(PARSE_AUTHORITY_EXTRA);
        if (extra != null && extra.trim().length() > 0){
            return false;
        }

        return true;
    }
protected boolean isValidAuthority ( String authority ) { if ( authority == null ) { return false ; } // check manual authority validation if specified if ( authorityValidator != null && authorityValidator . isValid ( authority ) ) { return true ; } // convert to ASCII if possible final String authorityASCII = DomainValidator . unicodeToASCII ( authority ) ; Matcher authorityMatcher = AUTHORITY_PATTERN . matcher ( authorityASCII ) ; if ( ! authorityMatcher . matches ( ) ) { return false ; } String hostLocation = authorityMatcher . group ( PARSE_AUTHORITY_HOST_IP ) ; // check if authority is hostname or IP address: // try a hostname first since that's much more likely DomainValidator domainValidator = DomainValidator . getInstance ( isOn ( ALLOW_LOCAL_URLS ) ) ; if ( ! domainValidator . isValid ( hostLocation ) ) { // try an IP address InetAddressValidator inetAddressValidator = InetAddressValidator . getInstance ( ) ; if ( ! inetAddressValidator . isValid ( hostLocation ) ) { // isn't either one, so the URL is invalid return false ; } } String port = authorityMatcher . group ( PARSE_AUTHORITY_PORT ) ; if ( port != null && ! PORT_PATTERN . matcher ( port ) . matches ( ) ) { return false ; } String extra = authorityMatcher . group ( PARSE_AUTHORITY_EXTRA ) ; if ( extra != null && extra . trim ( ) . length ( ) > 0 ) { return false ; } return true ; }
Returns true if the authority is properly formatted.  An authority is the combination
of hostname and port.  A <code>null</code> authority value is considered invalid.
Note: this implementation validates the domain unless a RegexValidator was provided.
If a RegexValidator was supplied and it matches, then the authority is regarded
as valid with no further checks, otherwise the method checks against the
AUTHORITY_PATTERN and the DomainValidator (ALLOW_LOCAL_URLS)
@param authority Authority value to validate, alllows IDN
@return true if authority (hostname and port) is valid.
Returns true if the authority is properly formatted . An authority is the combination of hostname and port . A <code > null< / code > authority value is considered invalid . Note : this implementation validates the domain unless a RegexValidator was provided . If a RegexValidator was supplied and it matches then the authority is regarded as valid with no further checks otherwise the method checks against the AUTHORITY_PATTERN and the DomainValidator ( ALLOW_LOCAL_URLS )