From 65184782aa1050e1f6d7dd687cdd7a0e345960e9 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Sun, 8 Nov 2015 10:33:41 +0100 Subject: [PATCH] OStatus usage of static Validate::* calls fixed --- plugins/OStatus/OStatusPlugin.php | 6 ++++-- plugins/OStatus/actions/ostatusinit.php | 3 ++- plugins/OStatus/actions/ostatussub.php | 5 +++-- plugins/OStatus/actions/pushhub.php | 2 +- plugins/OStatus/scripts/resub-feed.php | 4 +++- plugins/OStatus/scripts/testfeed.php | 4 +++- plugins/OStatus/scripts/update-profile-data.php | 3 ++- plugins/OStatus/scripts/update-profile.php | 4 +++- plugins/OStatus/scripts/update_ostatus_profiles.php | 5 +++-- 9 files changed, 24 insertions(+), 12 deletions(-) diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php index e8a3c2d666..f14c3057dd 100644 --- a/plugins/OStatus/OStatusPlugin.php +++ b/plugins/OStatus/OStatusPlugin.php @@ -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. diff --git a/plugins/OStatus/actions/ostatusinit.php b/plugins/OStatus/actions/ostatusinit.php index 5666c898af..64b47df498 100644 --- a/plugins/OStatus/actions/ostatusinit.php +++ b/plugins/OStatus/actions/ostatusinit.php @@ -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']); diff --git a/plugins/OStatus/actions/ostatussub.php b/plugins/OStatus/actions/ostatussub.php index f349b5d534..fb0d2ba758 100644 --- a/plugins/OStatus/actions/ostatussub.php +++ b/plugins/OStatus/actions/ostatussub.php @@ -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 diff --git a/plugins/OStatus/actions/pushhub.php b/plugins/OStatus/actions/pushhub.php index 5d0b9fbf90..d70a0c0c0c 100644 --- a/plugins/OStatus/actions/pushhub.php +++ b/plugins/OStatus/actions/pushhub.php @@ -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 { diff --git a/plugins/OStatus/scripts/resub-feed.php b/plugins/OStatus/scripts/resub-feed.php index 3d13724f7d..d5d0924fbf 100755 --- a/plugins/OStatus/scripts/resub-feed.php +++ b/plugins/OStatus/scripts/resub-feed.php @@ -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); } diff --git a/plugins/OStatus/scripts/testfeed.php b/plugins/OStatus/scripts/testfeed.php index 84b470c3b2..da1eee292e 100755 --- a/plugins/OStatus/scripts/testfeed.php +++ b/plugins/OStatus/scripts/testfeed.php @@ -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); } diff --git a/plugins/OStatus/scripts/update-profile-data.php b/plugins/OStatus/scripts/update-profile-data.php index e024ed95a7..ca48dc34a7 100755 --- a/plugins/OStatus/scripts/update-profile-data.php +++ b/plugins/OStatus/scripts/update-profile-data.php @@ -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 { diff --git a/plugins/OStatus/scripts/update-profile.php b/plugins/OStatus/scripts/update-profile.php index f20429cd83..c5d9aa897c 100755 --- a/plugins/OStatus/scripts/update-profile.php +++ b/plugins/OStatus/scripts/update-profile.php @@ -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); } diff --git a/plugins/OStatus/scripts/update_ostatus_profiles.php b/plugins/OStatus/scripts/update_ostatus_profiles.php index 2a32ae0491..3f54c83cda 100755 --- a/plugins/OStatus/scripts/update_ostatus_profiles.php +++ b/plugins/OStatus/scripts/update_ostatus_profiles.php @@ -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"; -- 2.39.5