Skip to content
This repository was archived by the owner on Nov 7, 2020. It is now read-only.

Commit 302f6c0

Browse files
committed
change lock strategy
1 parent fee0006 commit 302f6c0

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

lib/blobfolio/domain/domain.php

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -85,25 +85,21 @@ public static function parse_host($host) {
8585
else {
8686
r_cast::string($host, true);
8787

88-
// Lock UTF-8 Casting.
89-
$lock = constants::$str_lock;
90-
constants::$str_lock = true;
91-
92-
r_mb::trim($host);
88+
r_mb::trim($host, true);
9389

9490
// Cut off the path, if any.
9591
if (false !== ($start = v_mb::strpos($host, '/'))) {
96-
$host = v_mb::substr($host, 0, $start);
92+
$host = v_mb::substr($host, 0, $start, true);
9793
}
9894

9995
// Cut off the query, if any.
10096
if (false !== ($start = v_mb::strpos($host, '?'))) {
101-
$host = v_mb::substr($host, 0, $start);
97+
$host = v_mb::substr($host, 0, $start, true);
10298
}
10399

104100
// Cut off credentials, if any.
105101
if (false !== ($start = v_mb::strpos($host, '@'))) {
106-
$host = v_mb::substr($host, $start + 1);
102+
$host = v_mb::substr($host, $start + 1, null, true);
107103
}
108104

109105
// Is this an IPv6 address?
@@ -114,17 +110,16 @@ public static function parse_host($host) {
114110
(0 === strpos($host, '[')) &&
115111
false !== ($end = v_mb::strpos($host, ']'))
116112
) {
117-
$host = v_mb::substr($host, 1, $end - 1);
113+
$host = v_mb::substr($host, 1, $end - 1, true);
118114
r_sanitize::ip($host, true);
119115
}
120116
// Cut off port, if any.
121117
elseif (false !== ($start = v_mb::strpos($host, ':'))) {
122-
$host = v_mb::substr($host, 0, $start);
118+
$host = v_mb::substr($host, 0, $start, true);
123119
}
124120

125121
// If it is empty or invalid, there is nothing we can do.
126122
if (!strlen($host)) {
127-
constants::$str_lock = false;
128123
return false;
129124
}
130125

@@ -136,13 +131,11 @@ public static function parse_host($host) {
136131
}
137132

138133
// Lowercase it.
139-
r_mb::strtolower($host);
134+
r_mb::strtolower($host, false, true);
140135

141136
// Get rid of trailing periods.
142137
$host = ltrim($host, '.');
143138
$host = rtrim($host, '.');
144-
145-
constants::$str_lock = false;
146139
}
147140

148141
// Liberate IPv6 from its walls.
@@ -166,8 +159,8 @@ public static function parse_host($host) {
166159
// Gotta have length, and can't start or end with a dash.
167160
if (
168161
!strlen($v) ||
169-
'-' === substr($v, 0, 1) ||
170-
'-' === substr($v, -1)
162+
(0 === strpos($v, '-')) ||
163+
('-' === substr($v, -1))
171164
) {
172165
return false;
173166
}
@@ -331,7 +324,11 @@ public function is_ip(bool $restricted=true) {
331324
return !!filter_var($this->host, FILTER_VALIDATE_IP);
332325
}
333326

334-
return !!filter_var($this->host, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE);
327+
return !!filter_var(
328+
$this->host,
329+
FILTER_VALIDATE_IP,
330+
FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE
331+
);
335332
}
336333

337334
/**
@@ -348,7 +345,11 @@ public function has_dns() {
348345
$this->dns = $this->is_ip(false);
349346
}
350347
else {
351-
$this->dns = !!filter_var(gethostbyname("{$this->host}."), FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE);
348+
$this->dns = !!filter_var(
349+
gethostbyname("{$this->host}."),
350+
FILTER_VALIDATE_IP,
351+
FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE
352+
);
352353
}
353354
}
354355

0 commit comments

Comments
 (0)