Skip to content

Commit 5eb1c2d

Browse files
committed
Work-around HHVM < 3.19 returning ":" for unknown Unix socket addresses
1 parent 74a194f commit 5eb1c2d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Connection.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,17 @@ private function parseAddress($address)
146146
}
147147

148148
if ($this->unix) {
149-
// unknown addresses should not return a NULL-byte string
150-
if ($address === "\x00") {
149+
// work around unknown addresses should return null value: https://3v4l.org/5C1lo
150+
// PHP uses "\0" string and HHVM < 3.19 uses ":" string
151+
if ($address === "\x00" || $address === ':') {
151152
return null;
152153
}
153154

155+
// remove trailing colon from address for HHVM < 3.19
156+
if (substr($address, -1) === ':') {
157+
$address = (string)substr($address, 0, -1);
158+
}
159+
154160
return 'unix://' . $address;
155161
}
156162

0 commit comments

Comments
 (0)