Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix getting subnet of ipv4 mapped ipv6 addresses
Signed-off-by: Vincent Petry <[email protected]>
  • Loading branch information
PVince81 committed Nov 22, 2021
commit 7e08a4ab157b2be82c286c65ae18fa9199aeba80
2 changes: 2 additions & 0 deletions lib/private/Security/Normalizer/IpAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ public function getSubnet(): string {
$this->ip,
32
);
} elseif (substr(strtolower($this->ip), 0, 7) === '::ffff:') {
return '::ffff:' . $this->getIPv4Subnet(substr($this->ip, 7), 32);
}
return $this->getIPv6Subnet(
$this->ip,
Expand Down
4 changes: 4 additions & 0 deletions tests/lib/Security/Normalizer/IpAddressTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ public function subnetDataProvider() {
'192.168.0.123',
'192.168.0.123/32',
],
[
'::ffff:192.168.0.123',
'::ffff:192.168.0.123/32',
],
[
'2001:0db8:85a3:0000:0000:8a2e:0370:7334',
'2001:db8:85a3::/64',
Expand Down