mirror of
https://github.com/friendica/friendica
synced 2024-11-13 00:22:59 +00:00
Merge pull request #11490 from annando/issue-11487
Move IDN conversion behind the cleaning
This commit is contained in:
commit
7026dd37db
2 changed files with 12 additions and 9 deletions
|
@ -65,11 +65,11 @@ class Probe
|
||||||
*/
|
*/
|
||||||
public static function cleanURI(string $rawUri): string
|
public static function cleanURI(string $rawUri): string
|
||||||
{
|
{
|
||||||
$rawUri = Network::convertToIdn($rawUri);
|
|
||||||
|
|
||||||
// At first remove leading and trailing junk
|
// At first remove leading and trailing junk
|
||||||
$rawUri = trim($rawUri, "@#?:/ \t\n\r\0\x0B");
|
$rawUri = trim($rawUri, "@#?:/ \t\n\r\0\x0B");
|
||||||
|
|
||||||
|
$rawUri = Network::convertToIdn($rawUri);
|
||||||
|
|
||||||
$uri = new Uri($rawUri);
|
$uri = new Uri($rawUri);
|
||||||
if (!$uri->getScheme()) {
|
if (!$uri->getScheme()) {
|
||||||
return $uri->__toString();
|
return $uri->__toString();
|
||||||
|
|
|
@ -26,6 +26,7 @@ use Friendica\Core\Logger;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Network\HTTPException\NotModifiedException;
|
use Friendica\Network\HTTPException\NotModifiedException;
|
||||||
|
use GuzzleHttp\Psr7\Uri;
|
||||||
|
|
||||||
class Network
|
class Network
|
||||||
{
|
{
|
||||||
|
@ -436,7 +437,7 @@ class Network
|
||||||
* @param array $parsed URL parts
|
* @param array $parsed URL parts
|
||||||
*
|
*
|
||||||
* @return string The glued URL.
|
* @return string The glued URL.
|
||||||
* @deprecated since version 2021.12, use a UriInterface object like GuzzleHttp\Psr7\Uri instead
|
* @deprecated since version 2021.12, use GuzzleHttp\Psr7\Uri::fromParts($parts) instead
|
||||||
*/
|
*/
|
||||||
public static function unparseURL(array $parsed)
|
public static function unparseURL(array $parsed)
|
||||||
{
|
{
|
||||||
|
@ -473,12 +474,14 @@ class Network
|
||||||
$parts = parse_url($uri);
|
$parts = parse_url($uri);
|
||||||
if (!empty($parts['scheme']) && !empty($parts['host'])) {
|
if (!empty($parts['scheme']) && !empty($parts['host'])) {
|
||||||
$parts['host'] = idn_to_ascii($parts['host']);
|
$parts['host'] = idn_to_ascii($parts['host']);
|
||||||
$uri = self::unparseURL($parts);
|
$uri = Uri::fromParts($parts);
|
||||||
} elseif (strstr($uri, '@')) {
|
} else {
|
||||||
$host = idn_to_ascii(substr($uri, strpos($uri, '@') + 1));
|
$parts = explode('@', $uri);
|
||||||
$nick = substr($uri, 0, strpos($uri, '@'));
|
if (count($parts) == 2) {
|
||||||
|
$uri = $parts[0] . '@' . idn_to_ascii($parts[1]);
|
||||||
$uri = $nick . '@' . $host;
|
} else {
|
||||||
|
$uri = idn_to_ascii($uri);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $uri;
|
return $uri;
|
||||||
|
|
Loading…
Reference in a new issue