mirror of
https://git.freebsd.org/ports.git
synced 2025-05-29 17:36:28 -04:00
Submitted by: Phil Davis
Obtained from: 638b96a253
MFH: 2016Q4
Sponsored by: Rubicon Communications (Netgate)
36 lines
1,016 B
Text
36 lines
1,016 B
Text
From 638b96a253164b65c63825c38e79812b6c5f448d Mon Sep 17 00:00:00 2001
|
|
From: Phil Davis <phil.davis@inf.org>
|
|
Date: Thu, 27 Oct 2016 13:45:38 +0930
|
|
Subject: [PATCH] Fix compress to "::"
|
|
|
|
Problem:
|
|
```
|
|
Net_IPv6::compress("0:0:0:0:0:0:0:0");
|
|
```
|
|
returns the empty string.
|
|
|
|
It should return double-colon "::"
|
|
|
|
The preg_replace here are over-zealous, in the "::" case, the sring
|
|
starts and ends with ":" and so both get stripped out.
|
|
---
|
|
Net/IPv6.php | 6 ++++--
|
|
1 file changed, 4 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/Net/IPv6.php b/Net/IPv6.php
|
|
index ba77472..39949d1 100644
|
|
--- Net/IPv6.php
|
|
+++ Net/IPv6.php
|
|
@@ -734,8 +734,10 @@ public static function compress($ip, $force = false)
|
|
|
|
}
|
|
|
|
- $cip = preg_replace('/((^:)|(:$))/', '', $cip);
|
|
- $cip = preg_replace('/((^:)|(:$))/', '::', $cip);
|
|
+ if ($cip != "::") {
|
|
+ $cip = preg_replace('/((^:)|(:$))/', '', $cip);
|
|
+ $cip = preg_replace('/((^:)|(:$))/', '::', $cip);
|
|
+ }
|
|
|
|
if ('' != $netmask) {
|
|
|