@@ -1516,6 +1516,12 @@ private static boolean isValidHostName(String name) {
15161516 Pattern .compile ("^(\\ d{1,3})\\ .(\\ d{1,3})\\ .(\\ d{1,3})\\ .(\\ d{1,3})$" );
15171517 private static final int IPV4_MAX_OCTET_VALUE = 255 ;
15181518
1519+ /**
1520+ * Checks whether a given string represents a valid IPv4 address.
1521+ *
1522+ * @param name the name to validate
1523+ * @return true if the given name is a valid IPv4 address
1524+ */
15191525 // mostly copied from org.apache.commons.validator.routines.InetAddressValidator#isValidInet4Address
15201526 private static boolean isIPv4Address (String name ) {
15211527 Matcher m = IPV4_PATTERN .matcher (name );
@@ -1557,6 +1563,12 @@ private static boolean isIPv4Address(String name) {
15571563 private static final int BASE_16 = 16 ;
15581564
15591565 // copied from org.apache.commons.validator.routines.InetAddressValidator#isValidInet6Address
1566+ /**
1567+ * Checks whether a given string represents a valid IPv6 address.
1568+ *
1569+ * @param inet6Address the name to validate
1570+ * @return true if the given name is a valid IPv6 address
1571+ */
15601572 private static boolean isIPv6Address (String inet6Address ) {
15611573 boolean containsCompressedZeroes = inet6Address .contains ("::" );
15621574 if (containsCompressedZeroes && (inet6Address .indexOf ("::" ) != inet6Address .lastIndexOf ("::" ))) {
@@ -1622,6 +1634,14 @@ private static boolean isIPv6Address(String inet6Address) {
16221634
16231635 private static final Pattern REG_NAME_PART_PATTERN = Pattern .compile ("^[a-zA-Z0-9][a-zA-Z0-9-]*$" );
16241636
1637+ /**
1638+ * Checks whether a given string is a valid host name according to
1639+ * RFC 3986 - not accepting IP addresses.
1640+ *
1641+ * @see "https://tools.ietf.org/html/rfc3986#section-3.2.2"
1642+ * @param name the hostname to validate
1643+ * @return true if the given name is a valid host name
1644+ */
16251645 private static boolean isRFC3986HostName (String name ) {
16261646 String [] parts = name .split ("\\ ." , -1 );
16271647 for (int i = 0 ; i < parts .length ; i ++) {
0 commit comments