link_compare calls

implement compareLink function.
This commit is contained in:
Adam Magness 2018-11-08 10:46:50 -05:00
commit 5276c28a78
19 changed files with 32 additions and 30 deletions

View file

@ -53,7 +53,7 @@ function dirfind_content(App $a, $prefix = "") {
if (strpos($search,'@') === 0) {
$search = substr($search,1);
$header = L10n::t('People Search - %s', $search);
if ((valid_email($search) && Network::isEmailDomainValid($search)) ||
if ((Strings::isValidEmail($search) && Network::isEmailDomainValid($search)) ||
(substr(normalise_link($search), 0, 7) == "http://")) {
$user_data = Probe::uri($search);
$discover_user = (in_array($user_data["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::OSTATUS, Protocol::DIASPORA]));

View file

@ -56,7 +56,7 @@ function invite_post(App $a)
foreach ($recipients as $recipient) {
$recipient = trim($recipient);
if (! valid_email($recipient)) {
if (! Strings::isValidEmail($recipient)) {
notice(L10n::t('%s : Not a valid email address.', $recipient) . EOL);
continue;
}

View file

@ -348,7 +348,7 @@ function item_post(App $a) {
$str_tags = '';
$inform = '';
$tags = get_tags($body);
$tags = Strings::getTags($body);
// Add a tag if the parent contact is from ActivityPub or OStatus (This will notify them)
if ($parent && in_array($thr_parent_contact['network'], [Protocol::OSTATUS, Protocol::ACTIVITYPUB])) {

View file

@ -463,7 +463,7 @@ function render_messages(array $msg, $t)
foreach ($msg as $rr) {
if ($rr['unknown']) {
$participants = L10n::t("Unknown sender - %s", $rr['from-name']);
} elseif (link_compare($rr['from-url'], $myprofile)) {
} elseif (Strings::compareLink($rr['from-url'], $myprofile)) {
$participants = L10n::t("You and %s", $rr['name']);
} else {
$participants = L10n::t("%s and You", $rr['from-name']);

View file

@ -44,7 +44,7 @@ function openid_content(App $a) {
AND `blocked` = 0 AND `account_expired` = 0
AND `account_removed` = 0 AND `verified` = 1
LIMIT 1",
DBA::escape($authid), DBA::escape(normalise_openid($authid))
DBA::escape($authid), DBA::escape(Strings::normaliseOpenID($authid))
);
if (DBA::isResult($r)) {

View file

@ -525,7 +525,7 @@ function photos_post(App $a)
}
$taginfo = [];
$tags = get_tags($rawtags);
$tags = Strings::getTags($rawtags);
if (count($tags)) {
foreach ($tags as $tag) {

View file

@ -64,7 +64,7 @@ function pubsub_init(App $a)
hub_return(false, '');
}
if (!empty($hub_topic) && !link_compare($hub_topic, $contact['poll'])) {
if (!empty($hub_topic) && !Strings::compareLink($hub_topic, $contact['poll'])) {
Logger::log('Hub topic ' . $hub_topic . ' != ' . $contact['poll']);
hub_return(false, '');
}

View file

@ -88,7 +88,7 @@ function pubsubhubbub_init(App $a) {
// sanity check that topic URLs are the same
$hub_topic2 = str_replace('/feed/', '/dfrn_poll/', $hub_topic);
if (!link_compare($hub_topic, $contact['poll']) && !link_compare($hub_topic2, $contact['poll'])) {
if (!Strings::compareLink($hub_topic, $contact['poll']) && !Strings::compareLink($hub_topic2, $contact['poll'])) {
Logger::log('Hub topic ' . $hub_topic . ' != ' . $contact['poll']);
System::httpExit(404);
}

View file

@ -116,7 +116,7 @@ function redir_init(App $a) {
if (!empty($url)) {
$my_profile = Profile::getMyURL();
if (!empty($my_profile) && !link_compare($my_profile, $url)) {
if (!empty($my_profile) && !Strings::compareLink($my_profile, $url)) {
$separator = strpos($url, '?') ? '&' : '?';
$url .= $separator . 'zrl=' . urlencode($my_profile);

View file

@ -517,7 +517,7 @@ function settings_post(App $a)
$email = $a->user['email'];
}
// check the email is valid
if (!valid_email($email)) {
if (!Strings::isValidEmail($email)) {
$err .= L10n::t('Invalid email.');
}
// ensure new email is not the admin mail
@ -545,7 +545,7 @@ function settings_post(App $a)
$str_contact_deny = !empty($_POST['contact_deny']) ? perms2str($_POST['contact_deny']) : '';
$openidserver = $a->user['openidserver'];
//$openid = normalise_openid($openid);
//$openid = Strings::normaliseOpenID($openid);
// If openid has changed or if there's an openid but no openidserver, try and discover it.
if ($openid != $a->user['openid'] || (strlen($openid) && (!strlen($openidserver)))) {