]> git.mxchange.org Git - friendica.git/commitdiff
Throw an exception when parse_url fails in HttpClient->request
authorHypolite Petovan <hypolite@mrpetovan.com>
Thu, 19 Jan 2023 13:44:06 +0000 (08:44 -0500)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sat, 21 Jan 2023 19:25:21 +0000 (14:25 -0500)
- Address part of https://github.com/friendica/friendica/issues/12011#issuecomment-1383147421

src/Network/HTTPClient/Client/HttpClient.php

index 2ef704df1fafaeb000959bd39161f17f175276f6..4ee0842150c96a93e40e1776a9185c1cb9c1c8d2 100644 (file)
@@ -69,6 +69,10 @@ class HttpClient implements ICanSendHttpRequests
                $this->logger->debug('Request start.', ['url' => $url, 'method' => $method]);
 
                $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)) {
                        $this->logger->debug('URL cannot be resolved.', ['url' => $url, 'callstack' => System::callstack(20)]);
                        $this->profiler->stopRecording();