Throw an exception when parse_url fails in HttpClient->request
- Address part of https://github.com/friendica/friendica/issues/12011#issuecomment-1383147421
This commit is contained in:
parent
9ff3aca3b2
commit
881cb456e2
1 changed files with 4 additions and 0 deletions
|
@ -69,6 +69,10 @@ class HttpClient implements ICanSendHttpRequests
|
||||||
$this->logger->debug('Request start.', ['url' => $url, 'method' => $method]);
|
$this->logger->debug('Request start.', ['url' => $url, 'method' => $method]);
|
||||||
|
|
||||||
$host = parse_url($url, PHP_URL_HOST);
|
$host = parse_url($url, PHP_URL_HOST);
|
||||||
|
if (empty($host)) {
|
||||||
|
throw new \InvalidArgumentException('Unable to retrieve the host in URL: ' . $url);
|
||||||
|
}
|
||||||
|
|
||||||
if(!filter_var($host, FILTER_VALIDATE_IP) && !@dns_get_record($host . '.', DNS_A + DNS_AAAA) && !gethostbyname($host)) {
|
if(!filter_var($host, FILTER_VALIDATE_IP) && !@dns_get_record($host . '.', DNS_A + DNS_AAAA) && !gethostbyname($host)) {
|
||||||
$this->logger->debug('URL cannot be resolved.', ['url' => $url, 'callstack' => System::callstack(20)]);
|
$this->logger->debug('URL cannot be resolved.', ['url' => $url, 'callstack' => System::callstack(20)]);
|
||||||
$this->profiler->stopRecording();
|
$this->profiler->stopRecording();
|
||||||
|
|
Loading…
Reference in a new issue