mirror of
https://github.com/friendica/friendica
synced 2024-12-22 22:40:16 +00:00
"Network::unparseURL" is replaced with "Uri::fromParts"
This commit is contained in:
parent
a6f3c961dc
commit
1c66d49599
9 changed files with 17 additions and 49 deletions
|
@ -23,8 +23,8 @@ namespace Friendica\Content;
|
|||
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\Strings;
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
|
||||
/**
|
||||
* This pager should be used by lists using the min_id†/max_id† parameters
|
||||
|
@ -67,7 +67,7 @@ class BoundariesPager extends Pager
|
|||
|
||||
$parsed['query'] = http_build_query($queryParameters);
|
||||
|
||||
$url = Network::unparseURL($parsed);
|
||||
$url = (string)Uri::fromParts((array)$parsed);
|
||||
|
||||
$this->setQueryString($url);
|
||||
}
|
||||
|
|
|
@ -25,8 +25,8 @@ use Friendica\Core\Hook;
|
|||
use Friendica\Core\Protocol;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\Strings;
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
|
||||
/**
|
||||
* ContactSelector class
|
||||
|
@ -102,7 +102,7 @@ class ContactSelector
|
|||
// Create the server url out of the profile url
|
||||
$parts = parse_url($profile);
|
||||
unset($parts['path']);
|
||||
$server_url = Strings::normaliseLink(Network::unparseURL($parts));
|
||||
$server_url = Strings::normaliseLink((string)Uri::fromParts((array)$parts));
|
||||
}
|
||||
|
||||
self::$server_url[$profile] = $server_url;
|
||||
|
|
|
@ -29,9 +29,9 @@ use Friendica\Core\Renderer;
|
|||
use Friendica\Core\Search;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\Strings;
|
||||
use Friendica\Util\XML;
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
use League\HTMLToMarkdown\HtmlConverter;
|
||||
use Psr\Http\Message\UriInterface;
|
||||
|
||||
|
@ -407,7 +407,7 @@ class HTML
|
|||
}
|
||||
|
||||
$parts = array_merge($base, parse_url($url));
|
||||
$url2 = Network::unparseURL($parts);
|
||||
$url2 = (string)Uri::fromParts((array)$parts);
|
||||
|
||||
return str_replace($url, $url2, $link);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ use Friendica\Core\Logger;
|
|||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Network;
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
|
||||
class PushSubscriber
|
||||
{
|
||||
|
@ -179,7 +179,7 @@ class PushSubscriber
|
|||
|
||||
$parts = parse_url($subscriber['callback_url']);
|
||||
unset($parts['path']);
|
||||
$server_url = Network::unparseURL($parts);
|
||||
$server_url = (string)Uri::fromParts((array)$parts);
|
||||
$gsid = GServer::getID($server_url, true);
|
||||
if (!empty($gsid)) {
|
||||
GServer::setProtocol($gsid, Post\DeliveryData::OSTATUS);
|
||||
|
|
|
@ -26,7 +26,7 @@ use Friendica\Database\DBA;
|
|||
use Friendica\Model\GServer;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Util\Network;
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
|
||||
/**
|
||||
* Undocumented API endpoint that is implemented by both Mastodon and Pleroma
|
||||
|
@ -47,7 +47,7 @@ class Peers extends BaseApi
|
|||
while ($instance = DBA::fetch($instances)) {
|
||||
$urldata = parse_url($instance['url']);
|
||||
unset($urldata['scheme']);
|
||||
$return[] = ltrim(Network::unparseURL($urldata), '/');
|
||||
$return[] = ltrim((string)Uri::fromParts((array)$urldata), '/');
|
||||
}
|
||||
DBA::close($instances);
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ use GuzzleHttp\Client;
|
|||
use GuzzleHttp\Cookie\FileCookieJar;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use GuzzleHttp\Exception\TransferException;
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
use GuzzleHttp\RequestOptions;
|
||||
use mattwright\URLResolver;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
@ -104,7 +105,7 @@ class HttpClient implements ICanSendHttpRequests
|
|||
}
|
||||
}
|
||||
$parts['path'] = implode('/', $parts2);
|
||||
$url = Network::unparseURL($parts);
|
||||
$url = (string)Uri::fromParts((array)$parts);
|
||||
|
||||
if (Network::isUrlBlocked($url)) {
|
||||
$this->logger->info('Domain is blocked.', ['url' => $url]);
|
||||
|
|
|
@ -21,10 +21,9 @@
|
|||
|
||||
namespace Friendica\Network\HTTPClient\Response;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Network\HTTPClient\Capability\ICanHandleHttpResponses;
|
||||
use Friendica\Network\HTTPException\UnprocessableEntityException;
|
||||
use Friendica\Util\Network;
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
|
@ -224,7 +223,7 @@ class CurlResult implements ICanHandleHttpResponses
|
|||
}
|
||||
}
|
||||
|
||||
$this->redirectUrl = Network::unparseURL($redirect_parts);
|
||||
$this->redirectUrl = (string)Uri::fromParts((array)$redirect_parts);
|
||||
|
||||
$this->isRedirectUrl = true;
|
||||
} else {
|
||||
|
|
|
@ -1660,7 +1660,7 @@ class Probe
|
|||
unset($baseParts['query']);
|
||||
unset($baseParts['fragment']);
|
||||
|
||||
return Network::unparseURL((array)$baseParts);
|
||||
return (string)Uri::fromParts((array)(array)$baseParts);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -400,7 +400,7 @@ class Network
|
|||
];
|
||||
|
||||
$parts = array_merge($base, parse_url('/' . ltrim($url, '/')));
|
||||
return self::unparseURL($parts);
|
||||
return (string)Uri::fromParts((array)$parts);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -492,38 +492,6 @@ class Network
|
|||
return Strings::normaliseLink($match);
|
||||
}
|
||||
|
||||
/**
|
||||
* Glue url parts together
|
||||
*
|
||||
* @param array $parsed URL parts
|
||||
*
|
||||
* @return string|null The glued URL or null on error
|
||||
* @deprecated since version 2021.12, use GuzzleHttp\Psr7\Uri::fromParts($parts) instead
|
||||
*/
|
||||
public static function unparseURL(array $parsed): string
|
||||
{
|
||||
$get = function ($key) use ($parsed) {
|
||||
return isset($parsed[$key]) ? $parsed[$key] : null;
|
||||
};
|
||||
|
||||
$pass = $get('pass');
|
||||
$user = $get('user');
|
||||
$userinfo = $pass !== null ? "$user:$pass" : $user;
|
||||
$port = $get('port');
|
||||
$scheme = $get('scheme');
|
||||
$query = $get('query');
|
||||
$fragment = $get('fragment');
|
||||
$authority = ($userinfo !== null ? $userinfo . '@' : '') .
|
||||
$get('host') .
|
||||
($port ? ":$port" : '');
|
||||
|
||||
return (!empty($scheme) ? $scheme . ':' : '') .
|
||||
(!empty($authority) ? '//' . $authority : '') .
|
||||
$get('path') .
|
||||
(!empty($query) ? '?' . $query : '') .
|
||||
(!empty($fragment) ? '#' . $fragment : '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an URI to an IDN compatible URI
|
||||
*
|
||||
|
@ -602,7 +570,7 @@ class Network
|
|||
|
||||
$parsed['query'] = http_build_query($params);
|
||||
|
||||
return self::unparseURL($parsed);
|
||||
return (string)Uri::fromParts((array)$parsed);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue