mirror of
https://github.com/friendica/friendica
synced 2025-04-25 09:10:11 +00:00
Configurable list of domains to ignore redirects
This commit is contained in:
parent
26831371f7
commit
55e169db49
4 changed files with 52 additions and 2 deletions
|
@ -192,7 +192,7 @@ class HTTPRequest implements IHTTPRequest
|
|||
|
||||
$curlResponse = new CurlResult($url, $s, $curl_info, curl_errno($ch), curl_error($ch));
|
||||
|
||||
if ($curlResponse->isRedirectUrl()) {
|
||||
if (!Network::isRedirectBlocked($url) && $curlResponse->isRedirectUrl()) {
|
||||
$redirects++;
|
||||
$this->logger->notice('Curl redirect.', ['url' => $url, 'to' => $curlResponse->getRedirectUrl()]);
|
||||
@curl_close($ch);
|
||||
|
@ -280,7 +280,7 @@ class HTTPRequest implements IHTTPRequest
|
|||
|
||||
$curlResponse = new CurlResult($url, $s, $curl_info, curl_errno($ch), curl_error($ch));
|
||||
|
||||
if ($curlResponse->isRedirectUrl()) {
|
||||
if (!Network::isRedirectBlocked($url) && $curlResponse->isRedirectUrl()) {
|
||||
$redirects++;
|
||||
$this->logger->info('Post redirect.', ['url' => $url, 'to' => $curlResponse->getRedirectUrl()]);
|
||||
curl_close($ch);
|
||||
|
@ -321,6 +321,11 @@ class HTTPRequest implements IHTTPRequest
|
|||
return $url;
|
||||
}
|
||||
|
||||
if (Network::isRedirectBlocked($url)) {
|
||||
$this->logger->info('Domain should not be redirected.', ['url' => $url]);
|
||||
return $url;
|
||||
}
|
||||
|
||||
$url = Network::stripTrackingQueryParams($url);
|
||||
|
||||
if ($depth > 10) {
|
||||
|
@ -470,4 +475,14 @@ class HTTPRequest implements IHTTPRequest
|
|||
DB_UPDATE_VERSION . '; ' .
|
||||
$this->baseUrl;
|
||||
}
|
||||
|
||||
private function redirectBlocked(string $url = null)
|
||||
{
|
||||
$hosts = $this->config->get('system', 'no_redirect_hosts');
|
||||
if (empty($hosts)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$hostlist = explode(',', $hosts);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue