@Test public void testValidateSearchStringIsValidIdnaException() { assertFalse(validateSearchStringIsValidIdna("cnnic%.cn*")); assertFalse(validateSearchStringIsValidIdna("%E%B8%AD%E5%9B%BD%E4%BA%92%E8%81%94%E7%BD%91%E7%BB%9C%E4%BF%A1%E6%81%AF%E4%B8%AD%E5%BF%83.cn*")); }
public static boolean validateSearchStringIsValidIdna(String searchString) { if (StringUtils.isBlank(searchString)) { return false; } if (searchString.contains(BLANK_IN_DOMAIN)) { return false; } if (1 < StringUtils.countMatches(searchString, StringUtil.ASTERISK)) { return false; } String domainName = searchString.replace(StringUtil.ASTERISK, ""); if (validateDomainNameIsValidIdna(domainName, true)) { return true; } domainName = searchString.replace(StringUtil.ASTERISK, StringUtil.TLD_SPLITOR); if (validateDomainNameIsValidIdna(domainName, true)) { return true; } domainName = searchString.replace(StringUtil.ASTERISK, "1"); if (validateDomainNameIsValidIdna(domainName, true)) { return true; } domainName = searchString.replace("*", ".1"); if (validateDomainNameIsValidIdna(domainName, true)) { return true; } domainName = searchString.replace("*", "1.1"); if (validateDomainNameIsValidIdna(domainName, true)) { return true; } return false; }
DomainUtil { public static boolean validateSearchStringIsValidIdna(String searchString) { if (StringUtils.isBlank(searchString)) { return false; } if (searchString.contains(BLANK_IN_DOMAIN)) { return false; } if (1 < StringUtils.countMatches(searchString, StringUtil.ASTERISK)) { return false; } String domainName = searchString.replace(StringUtil.ASTERISK, ""); if (validateDomainNameIsValidIdna(domainName, true)) { return true; } domainName = searchString.replace(StringUtil.ASTERISK, StringUtil.TLD_SPLITOR); if (validateDomainNameIsValidIdna(domainName, true)) { return true; } domainName = searchString.replace(StringUtil.ASTERISK, "1"); if (validateDomainNameIsValidIdna(domainName, true)) { return true; } domainName = searchString.replace("*", ".1"); if (validateDomainNameIsValidIdna(domainName, true)) { return true; } domainName = searchString.replace("*", "1.1"); if (validateDomainNameIsValidIdna(domainName, true)) { return true; } return false; } }
DomainUtil { public static boolean validateSearchStringIsValidIdna(String searchString) { if (StringUtils.isBlank(searchString)) { return false; } if (searchString.contains(BLANK_IN_DOMAIN)) { return false; } if (1 < StringUtils.countMatches(searchString, StringUtil.ASTERISK)) { return false; } String domainName = searchString.replace(StringUtil.ASTERISK, ""); if (validateDomainNameIsValidIdna(domainName, true)) { return true; } domainName = searchString.replace(StringUtil.ASTERISK, StringUtil.TLD_SPLITOR); if (validateDomainNameIsValidIdna(domainName, true)) { return true; } domainName = searchString.replace(StringUtil.ASTERISK, "1"); if (validateDomainNameIsValidIdna(domainName, true)) { return true; } domainName = searchString.replace("*", ".1"); if (validateDomainNameIsValidIdna(domainName, true)) { return true; } domainName = searchString.replace("*", "1.1"); if (validateDomainNameIsValidIdna(domainName, true)) { return true; } return false; } private  DomainUtil(); }
DomainUtil { public static boolean validateSearchStringIsValidIdna(String searchString) { if (StringUtils.isBlank(searchString)) { return false; } if (searchString.contains(BLANK_IN_DOMAIN)) { return false; } if (1 < StringUtils.countMatches(searchString, StringUtil.ASTERISK)) { return false; } String domainName = searchString.replace(StringUtil.ASTERISK, ""); if (validateDomainNameIsValidIdna(domainName, true)) { return true; } domainName = searchString.replace(StringUtil.ASTERISK, StringUtil.TLD_SPLITOR); if (validateDomainNameIsValidIdna(domainName, true)) { return true; } domainName = searchString.replace(StringUtil.ASTERISK, "1"); if (validateDomainNameIsValidIdna(domainName, true)) { return true; } domainName = searchString.replace("*", ".1"); if (validateDomainNameIsValidIdna(domainName, true)) { return true; } domainName = searchString.replace("*", "1.1"); if (validateDomainNameIsValidIdna(domainName, true)) { return true; } return false; } private  DomainUtil(); static boolean isArpaTldAndLabelIsValid(String domainName); static boolean validateDomainNameIsValidIdna(String domainName,
            boolean forSearch); static boolean validateSearchStringIsValidIdna(String searchString); static String deleteLastPoint(String paramStr); static String getLowerCaseByLabel(String str); static String safeGeneDomainPunyName(String domainName); static String geneDomainPunyName(String domainName); static String urlDecodeAndReplaceAsciiToLowercase(String str); static String replaceAsciiToLowercase(String str); static String urlDecode(String str); static String iso8859Decode(String str); static boolean isLdh(String domain); static boolean validateSearchLdnName(String searchString); }
DomainUtil { public static boolean validateSearchStringIsValidIdna(String searchString) { if (StringUtils.isBlank(searchString)) { return false; } if (searchString.contains(BLANK_IN_DOMAIN)) { return false; } if (1 < StringUtils.countMatches(searchString, StringUtil.ASTERISK)) { return false; } String domainName = searchString.replace(StringUtil.ASTERISK, ""); if (validateDomainNameIsValidIdna(domainName, true)) { return true; } domainName = searchString.replace(StringUtil.ASTERISK, StringUtil.TLD_SPLITOR); if (validateDomainNameIsValidIdna(domainName, true)) { return true; } domainName = searchString.replace(StringUtil.ASTERISK, "1"); if (validateDomainNameIsValidIdna(domainName, true)) { return true; } domainName = searchString.replace("*", ".1"); if (validateDomainNameIsValidIdna(domainName, true)) { return true; } domainName = searchString.replace("*", "1.1"); if (validateDomainNameIsValidIdna(domainName, true)) { return true; } return false; } private  DomainUtil(); static boolean isArpaTldAndLabelIsValid(String domainName); static boolean validateDomainNameIsValidIdna(String domainName,
            boolean forSearch); static boolean validateSearchStringIsValidIdna(String searchString); static String deleteLastPoint(String paramStr); static String getLowerCaseByLabel(String str); static String safeGeneDomainPunyName(String domainName); static String geneDomainPunyName(String domainName); static String urlDecodeAndReplaceAsciiToLowercase(String str); static String replaceAsciiToLowercase(String str); static String urlDecode(String str); static String iso8859Decode(String str); static boolean isLdh(String domain); static boolean validateSearchLdnName(String searchString); static final String XN_PREFIX; static final String ACE_PREFIX; static final int MAX_DOMAIN_LENGTH_WITHOUT_LAST_DOT; static final int MIN_DOMAIN_LENGTH_WITHOUT_LAST_DOT; static final String ARPA_SUFFIX; static final String IPV4_ARPA_SUFFIX; static final String IPV6_ARPA_SUFFIX; static final int MAX_ASCII_CODE; static final String BLANK_IN_DOMAIN; static final java.lang.String DISALLOWED_DELIMITERS; }