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 authored and backportbot[bot] committed Nov 23, 2021
commit 87af149292d3b377845664bf170b923042b53295
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 @@ -35,6 +35,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