arturobernalg opened a new pull request, #13496:
URL: https://github.com/apache/maven/pull/13496

   Fixes #8320
   
   ### What and why
   
   `external:*` and `external:http:*` mirror rules only treated `localhost` and 
`127.0.0.1` as local. A repository on another address of the loopback range, 
such as `127.0.0.2`, or on an IPv6 loopback address was classified as external 
and got mirrored. A bracketed IPv6 host such as `[::1]` was not even parsed as 
a host, because the URL pattern stops at the first colon.
   
   ### How
   
   `isLocal` now accepts `localhost`, an IPv4 address of `127.0.0.0/8` and an 
IPv6 loopback address in brackets, and the URL pattern accepts a bracketed 
host. Names are not resolved: an IP literal is parsed without a lookup, and 
`127.0.0.1.example.com` or `127.example.com` stay external. The same change is 
made in `MavenRepositorySystem` (v3 bridge) and in the compat 
`DefaultMirrorSelector`, which carry the same code.
   
   The mirror selector of Maven Resolver has the same limitation, as noted in 
the issue. That is a separate repository and is not touched here.
   
   ### Tests
   
   `MavenRepositorySystemTest` and `DefaultMirrorSelectorTest` each get one 
test for loopback addresses (`127.0.0.2`, `127.255.255.254:8080`, `[::1]`, 
`[::1]:8080`, the long IPv6 form) and one for addresses that must stay external 
(`128.0.0.1`, the two host names above, `[2001:db8::1]`). The loopback test 
fails on master (`http://127.0.0.2/m2/ expected: <false> but was: <true>`) and 
passes with the change, three runs in a row. `maven-compat` and `maven-core` 
pass and spotless is clean. I did not run the integration tests.
   
   ---
   
   To make clear that you license your contribution under
   the [Apache License Version 2.0, January 
2004](https://www.apache.org/licenses/LICENSE-2.0)
   check one of the following:
   
   - [ ] I hereby declare this contribution to be licensed under the [Apache 
License Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0)
   - [ ] I hereby declare that I have filed an [Apache Individual Contributor 
License Agreement](https://www.apache.org/licenses/icla.pdf).
   


-- 
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]

Reply via email to