-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow bracket IPv6 address format inside IPAdress Normalizer #13327
Allow bracket IPv6 address format inside IPAdress Normalizer #13327
Conversation
When run with php's build-in server (for instance on localhost:8080), IP provided through $this->server['REMOTE_ADDR'] is [::1], which is not an acceptable format for \inet_pton. This removes the brackets if there's any. Signed-off-by: Thomas Citharel <tcit@tcit.fr>
@@ -68,6 +68,9 @@ private function getIPv4Subnet(string $ip, int $maskBits = 32): string { | |||
* @return string | |||
*/ | |||
private function getIPv6Subnet(string $ip, int $maskBits = 48): string { | |||
if ($ip[0] === '[' && $ip[-1] === ']') { // If IP is with brackets, for example [::1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trim($ip, '[]'))
would also work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code makes sense 👍
@ChristophWurst Mind to review this one? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense! Thank you!
Fix #13943
When run with php's build-in server (for instance on
localhost:8080
), IP provided through$this->server['REMOTE_ADDR']
is[::1]
, which is not an acceptable format for \inet_pton.I didn't dig why I've got an IPv6 localhost or anything, but I guess it's still valid.
This removes the brackets if there's any.