You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "arturobernalg (via GitHub)" <gi...@apache.org> on 2023/02/10 11:31:08 UTC

[GitHub] [httpcomponents-core] arturobernalg opened a new pull request, #388: Fix the issue with invalid scoped IPv6 addresses in InetAddressUtils.

arturobernalg opened a new pull request, #388:
URL: https://github.com/apache/httpcomponents-core/pull/388

   This Pull Request addresses the issue of properly handling scoped IPv6 addresses in the InetAddressUtils class. The previous implementation had incorrect behavior when handling scoped IPv6 addresses. This fix updates the logic to properly check the format of the scope ID and to return false when the address is not a valid standard or compressed IPv6 address.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] [httpcomponents-core] ok2c commented on pull request #388: Fix the issue with invalid scoped IPv6 addresses in InetAddressUtils.

Posted by "ok2c (via GitHub)" <gi...@apache.org>.
ok2c commented on PR #388:
URL: https://github.com/apache/httpcomponents-core/pull/388#issuecomment-1425939043

   @arturobernalg Could you please change the target branch to 5.3.x? Otherwise looks good.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] [httpcomponents-core] ok2c merged pull request #388: Fix the issue with invalid scoped IPv6 addresses in InetAddressUtils.

Posted by "ok2c (via GitHub)" <gi...@apache.org>.
ok2c merged PR #388:
URL: https://github.com/apache/httpcomponents-core/pull/388


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] [httpcomponents-core] arturobernalg commented on a diff in pull request #388: Fix the issue with invalid scoped IPv6 addresses in InetAddressUtils.

Posted by "arturobernalg (via GitHub)" <gi...@apache.org>.
arturobernalg commented on code in PR #388:
URL: https://github.com/apache/httpcomponents-core/pull/388#discussion_r1102728702


##########
httpcore5/src/main/java/org/apache/hc/core5/net/InetAddressUtils.java:
##########
@@ -139,7 +152,32 @@ public static boolean isIPv6HexCompressedAddress(final String input) {
      * @return true if the input parameter is a valid standard or compressed IPv6 address
      */
     public static boolean isIPv6Address(final String input) {
-        return isIPv6StdAddress(input) || isIPv6HexCompressedAddress(input);
+        final int index = input.indexOf(SCOPE_ID_DELIMITER);
+        if (index == -1) {
+            return isIPv6StdAddress(input) || isIPv6HexCompressedAddress(input);
+        } else {
+            return isIPv6ScopedAddress(input);
+        }
+    }
+
+    /**
+     * Determines whether the given string represents a valid scoped IPv6 address.
+     * A scoped IPv6 address includes a scope identifier (e.g. "fe80::1ff:fe23:4567:890a%eth2").
+     *
+     * @param input the string to be tested
+     * @return {@code true} if the string represents a valid scoped IPv6 address, {@code false} otherwise
+     */
+    private static boolean isIPv6ScopedAddress(final String input) {
+        final int index = input.indexOf(SCOPE_ID_DELIMITER);

Review Comment:
   hi @ok2c 
   Yes. sound logical.
   TY



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] [httpcomponents-core] ok2c commented on a diff in pull request #388: Fix the issue with invalid scoped IPv6 addresses in InetAddressUtils.

Posted by "ok2c (via GitHub)" <gi...@apache.org>.
ok2c commented on code in PR #388:
URL: https://github.com/apache/httpcomponents-core/pull/388#discussion_r1102701888


##########
httpcore5/src/main/java/org/apache/hc/core5/net/InetAddressUtils.java:
##########
@@ -139,7 +152,32 @@ public static boolean isIPv6HexCompressedAddress(final String input) {
      * @return true if the input parameter is a valid standard or compressed IPv6 address
      */
     public static boolean isIPv6Address(final String input) {
-        return isIPv6StdAddress(input) || isIPv6HexCompressedAddress(input);
+        final int index = input.indexOf(SCOPE_ID_DELIMITER);
+        if (index == -1) {
+            return isIPv6StdAddress(input) || isIPv6HexCompressedAddress(input);
+        } else {
+            return isIPv6ScopedAddress(input);
+        }
+    }
+
+    /**
+     * Determines whether the given string represents a valid scoped IPv6 address.
+     * A scoped IPv6 address includes a scope identifier (e.g. "fe80::1ff:fe23:4567:890a%eth2").
+     *
+     * @param input the string to be tested
+     * @return {@code true} if the string represents a valid scoped IPv6 address, {@code false} otherwise
+     */
+    private static boolean isIPv6ScopedAddress(final String input) {
+        final int index = input.indexOf(SCOPE_ID_DELIMITER);

Review Comment:
   @arturobernalg How about folding this method into `#isIPv6Address` and doing `input.indexOf(SCOPE_ID_DELIMITER)` only once?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org