Commit 65184782 authored by mmn's avatar mmn

OStatus usage of static Validate::* calls fixed

parent f29daa22
......@@ -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.
......
......@@ -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']);
......
......@@ -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
......
......@@ -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 {
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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 {
......
......@@ -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);
}
......
......@@ -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";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment