yin-bo-Final opened a new issue, #16308:
URL: https://github.com/apache/dubbo/issues/16308

   ### Pre-check
   
   - [x] I am sure that all the content I provide is in English.
   
   
   ### Search before asking
   
   - [x] I had searched in the 
[issues](https://github.com/apache/dubbo/issues?q=is%3Aissue) and found no 
similar issues.
   
   
   ### Apache Dubbo Component
   
   Java SDK (apache/dubbo)
   
   ### Dubbo Version
   
   Dubbo 3.3.7 , OpenJDK 17 , Ubuntu
   
   ### Steps to reproduce this issue
   
   1. Add the following test case to 
`dubbo-common/src/test/java/org/apache/dubbo/common/utils/NetUtilsTest.java`:
   
   ```java
   @Test
   void testMatchIpExpressionWithIpv4AddressAndPort() throws 
UnknownHostException {
       assertTrue(NetUtils.matchIpExpression("*.*.*.*:90", "192.168.1.63:90"));
       assertTrue(NetUtils.matchIpExpression("192.168.1.*:90", 
"192.168.1.63:90"));
       assertFalse(NetUtils.matchIpExpression("192.168.1.*:80", 
"192.168.1.63:90"));
   }
   ```
   
   2. Run the test:
   ```bash
   ./mvnw -pl dubbo-common 
-Dtest=NetUtilsTest#testMatchIpExpressionWithIpv4AddressAndPort test
   ```
   
   
   3. The test fails because `192.168.1.63:90` is treated as the host instead 
of being parsed into host `192.168.1.63` and port `90`.
   ```bash
   ./mvnw -pl dubbo-common 
-Dtest=NetUtilsTest#testMatchIpExpressionWithIpv4AddressAndPort test
   ```
   
   
   
   ### What you expected to happen
   
   `NetUtils.matchIpExpression(String pattern, String address)` should 
correctly parse a normal IPv4 address with port, such as `192.168.1.63:90`, 
into host `192.168.1.63` and port `90`.
   
   For example:
   
   - `NetUtils.matchIpExpression("*.*.*.*:90", "192.168.1.63:90")` should 
return `true`.
   - `NetUtils.matchIpExpression("192.168.1.*:90", "192.168.1.63:90")` should 
return `true`.
   - `NetUtils.matchIpExpression("192.168.1.*:80", "192.168.1.63:90")` should 
return `false`.
   
   ### Anything else
   
   This appears to be a small parsing bug in 
`NetUtils.matchIpExpression(String, String)`. The fix should avoid affecting 
IPv6 addresses, because IPv6 addresses also contain colons.
   
   ### Do you have a (mini) reproduction demo?
   
   - [x] Yes, I have a minimal reproduction demo to help resolve this issue 
more effectively!
   
   ### Are you willing to submit a pull request to fix on your own?
   
   - [x] Yes I am willing to submit a pull request on my own!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to