@@ 140-143 (lines=4) @@ | ||
137 | */ |
|
138 | public function validateIP($ipAddress = null) |
|
139 | { |
|
140 | if ($ipAddress === null) { |
|
141 | $parsed = parse_url($this->uri); |
|
142 | $ipAddress = isset($parsed['host']) ? $parsed['host'] : null; |
|
143 | } |
|
144 | return ( |
|
145 | filter_var($ipAddress, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) || |
|
146 | filter_var(trim($ipAddress, '[]'), FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) |
|
@@ 160-163 (lines=4) @@ | ||
157 | */ |
|
158 | public function validateHost($host = null) |
|
159 | { |
|
160 | if ($host === null) { |
|
161 | $parsed = parse_url($this->uri); |
|
162 | $host = isset($parsed['host']) ? $parsed['host'] : $parsed['path']; |
|
163 | } |
|
164 | return ( |
|
165 | preg_match("/^([a-z\d](-*[a-z\d])*)(\.([a-z\d](-*[a-z\d])*))*$/i", $host) //valid chars check |
|
166 | && preg_match("/^.{1,253}$/", $host) //overall length check |
|
@@ 180-183 (lines=4) @@ | ||
177 | */ |
|
178 | public function validateScheme($scheme = null) |
|
179 | { |
|
180 | if ($scheme === null) { |
|
181 | $parsed = parse_url($this->uri); |
|
182 | $scheme = isset($parsed['host']) ? $parsed['host'] : $parsed['path']; |
|
183 | } |
|
184 | return in_array($scheme, $this->schemes); |
|
185 | } |
|
186 |