mirror of
https://github.com/friendica/friendica
synced 2025-05-01 21:44:27 +02:00
normalise_link calls
implement normaliseLink function
This commit is contained in:
parent
5276c28a78
commit
ffc406d819
54 changed files with 248 additions and 222 deletions
|
@ -9,6 +9,7 @@ use Friendica\Core\Logger;
|
|||
use Friendica\Core\System;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Network\CurlResult;
|
||||
use Friendica\Util\Strings;
|
||||
use DOMDocument;
|
||||
use DomXPath;
|
||||
|
||||
|
@ -718,8 +719,8 @@ class Network
|
|||
return "";
|
||||
}
|
||||
|
||||
$url1 = normalise_link($url1);
|
||||
$url2 = normalise_link($url2);
|
||||
$url1 = Strings::normaliseLink($url1);
|
||||
$url2 = Strings::normaliseLink($url2);
|
||||
|
||||
$parts1 = parse_url($url1);
|
||||
$parts2 = parse_url($url2);
|
||||
|
@ -790,7 +791,7 @@ class Network
|
|||
|
||||
$match .= $path;
|
||||
|
||||
return normalise_link($match);
|
||||
return Strings::normaliseLink($match);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,6 +12,7 @@ use Friendica\Core\Addon;
|
|||
use Friendica\Core\Logger;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Object\Image;
|
||||
use Friendica\Util\Strings;
|
||||
|
||||
require_once 'include/dba.php';
|
||||
|
||||
|
@ -49,7 +50,7 @@ class ParseUrl
|
|||
}
|
||||
|
||||
$parsed_url = DBA::selectFirst('parsed_url', ['content'],
|
||||
['url' => normalise_link($url), 'guessing' => !$no_guessing, 'oembed' => $do_oembed]
|
||||
['url' => Strings::normaliseLink($url), 'guessing' => !$no_guessing, 'oembed' => $do_oembed]
|
||||
);
|
||||
if (!empty($parsed_url['content'])) {
|
||||
$data = unserialize($parsed_url['content']);
|
||||
|
@ -61,7 +62,7 @@ class ParseUrl
|
|||
DBA::insert(
|
||||
'parsed_url',
|
||||
[
|
||||
'url' => normalise_link($url), 'guessing' => !$no_guessing,
|
||||
'url' => Strings::normaliseLink($url), 'guessing' => !$no_guessing,
|
||||
'oembed' => $do_oembed, 'content' => serialize($data),
|
||||
'created' => DateTimeFormat::utcNow()
|
||||
],
|
||||
|
|
|
@ -6,6 +6,7 @@ use Friendica\BaseModule;
|
|||
use Friendica\BaseObject;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Util\Strings;
|
||||
|
||||
/**
|
||||
* @brief Proxy utilities class
|
||||
|
@ -76,7 +77,7 @@ class Proxy
|
|||
|
||||
// Only continue if it isn't a local image and the isn't deactivated
|
||||
if (self::isLocalImage($url)) {
|
||||
$url = str_replace(normalise_link(System::baseUrl()) . '/', System::baseUrl() . '/', $url);
|
||||
$url = str_replace(Strings::normaliseLink(System::baseUrl()) . '/', System::baseUrl() . '/', $url);
|
||||
return $url;
|
||||
}
|
||||
|
||||
|
@ -140,7 +141,7 @@ class Proxy
|
|||
*/
|
||||
public static function proxifyHtml($html)
|
||||
{
|
||||
$html = str_replace(normalise_link(System::baseUrl()) . '/', System::baseUrl() . '/', $html);
|
||||
$html = str_replace(Strings::normaliseLink(System::baseUrl()) . '/', System::baseUrl() . '/', $html);
|
||||
|
||||
return preg_replace_callback('/(<img [^>]*src *= *["\'])([^"\']+)(["\'][^>]*>)/siU', 'self::replaceUrl', $html);
|
||||
}
|
||||
|
@ -162,8 +163,8 @@ class Proxy
|
|||
}
|
||||
|
||||
// links normalised - bug #431
|
||||
$baseurl = normalise_link(System::baseUrl());
|
||||
$url = normalise_link($url);
|
||||
$baseurl = Strings::normaliseLink(System::baseUrl());
|
||||
$url = Strings::normaliseLink($url);
|
||||
|
||||
return (substr($url, 0, strlen($baseurl)) == $baseurl);
|
||||
}
|
||||
|
|
|
@ -369,7 +369,7 @@ class Strings
|
|||
*
|
||||
* @return string Normalized URL.
|
||||
*/
|
||||
public static function normaliseLink($url) // normalise_link()
|
||||
public static function normaliseLink($url)
|
||||
{
|
||||
$ret = str_replace(['https:', '//www.'], ['http:', '//'], $url);
|
||||
return rtrim($ret, '/');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue