OStatus usage of static Validate::* calls fixed

This commit is contained in:
Mikael Nordfeldth 2015-11-08 10:33:41 +01:00
parent f29daa22b6
commit 65184782aa
9 changed files with 24 additions and 12 deletions

View File

@ -246,11 +246,13 @@ class OStatusPlugin extends Plugin
$profile->whereAdd('uri LIKE "%' . $profile->escape($q) . '%"');
$profile->query();
$validate = new Validate();
if ($profile->N == 0) {
try {
if (Validate::email($q)) {
if ($validate->email($q)) {
$oprofile = Ostatus_profile::ensureWebfinger($q);
} else if (Validate::uri($q)) {
} else if ($validate->uri($q)) {
$oprofile = Ostatus_profile::ensureProfileURL($q);
} else {
// TRANS: Exception in OStatus when invalid URI was entered.

View File

@ -153,8 +153,9 @@ class OStatusInitAction extends Action
function ostatusConnect()
{
$validate = new Validate();
$opts = array('allowed_schemes' => array('http', 'https', 'acct'));
if (Validate::uri($this->profile, $opts)) {
if ($validate->uri($this->profile, $opts)) {
$bits = parse_url($this->profile);
if ($bits['scheme'] == 'acct') {
$this->connectWebfinger($bits['path']);

View File

@ -241,11 +241,12 @@ class OStatusSubAction extends Action
*/
function pullRemoteProfile()
{
$validate = new Validate();
$this->profile_uri = $this->trimmed('profile');
try {
if (Validate::email($this->profile_uri)) {
if ($validate->email($this->profile_uri)) {
$this->oprofile = Ostatus_profile::ensureWebfinger($this->profile_uri);
} else if (Validate::uri($this->profile_uri)) {
} else if ($validate->uri($url, $params)) {
$this->oprofile = Ostatus_profile::ensureProfileURL($this->profile_uri);
} else {
// TRANS: Error message in OStatus plugin. Do not translate the domain names example.com

View File

@ -200,7 +200,7 @@ class PushHubAction extends Action
$url = $this->arg($arg);
$params = array('domain_check' => false, // otherwise breaks my local tests :P
'allowed_schemes' => array('http', 'https'));
$validate = new Validate;
$validate = new Validate();
if ($validate->uri($url, $params)) {
return $url;
} else {

View File

@ -36,7 +36,9 @@ END_OF_HELP;
require_once INSTALLDIR.'/scripts/commandline.inc';
if (empty($args[0]) || !Validate::uri($args[0])) {
$validate = new Validate();
if (empty($args[0]) || !$validate->uri($args[0])) {
print "$helptext";
exit(1);
}

View File

@ -35,7 +35,9 @@ END_OF_HELP;
require_once INSTALLDIR.'/scripts/commandline.inc';
if (empty($args[0]) || !Validate::uri($args[0])) {
$validate = new Validate();
if (empty($args[0]) || !$validate->uri($args[0])) {
print "$helptext";
exit(1);
}

View File

@ -99,6 +99,7 @@ function fixProfile($uri) {
}
$ok = true;
$validate = new Validate();
if (have_option('all')) {
$oprofile = new Ostatus_profile();
$oprofile->find();
@ -115,7 +116,7 @@ if (have_option('all')) {
while ($oprofile->fetch()) {
$ok = fixProfile($oprofile->uri) && $ok;
}
} else if (!empty($args[0]) && Validate::uri($args[0])) {
} else if (!empty($args[0]) && $validate->uri($args[0])) {
$uri = $args[0];
$ok = fixProfile($uri);
} else {

View File

@ -32,7 +32,9 @@ END_OF_HELP;
require_once INSTALLDIR.'/scripts/commandline.inc';
if (empty($args[0]) || !Validate::uri($args[0])) {
$validate = new Validate();
if (empty($args[0]) || !$validate->uri($args[0])) {
print "$helptext";
exit(1);
}

View File

@ -207,10 +207,11 @@ class LooseOstatusProfile extends Ostatus_profile
function pullOstatusProfile($uri) {
$oprofile = null;
$validate = new Validate();
if (Validate::email($uri)) {
if ($validate->email($uri)) {
$oprofile = LooseOstatusProfile::updateWebfinger($uri);
} else if (Validate::uri($uri)) {
} else if ($validate->uri($uri)) {
$oprofile = LooseOstatusProfile::updateProfileURL($uri);
} else {
print "Sorry, we could not reach the address: $uri\n";