]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/OStatus/actions/ostatussub.php
Empty resource would throw exception
[quix0rs-gnu-social.git] / plugins / OStatus / actions / ostatussub.php
index 8a8cfb9880eaf0cb7138840b4288d2100dfb7bbc..7531bb688644faa556684b799566702f317daf6d 100644 (file)
@@ -155,8 +155,8 @@ class OStatusSubAction extends Action
      */
     function preview()
     {
-        $oprofile = $this->oprofile;
-        $profile = $oprofile->localProfile();
+        // Throws NoProfileException on localProfile when remote user's Profile not found
+        $profile = $this->oprofile->localProfile();
 
         if ($this->scoped->isSubscribed($profile)) {
             $this->element('div', array('class' => 'error'),
@@ -193,31 +193,31 @@ class OStatusSubAction extends Action
         $hasFN = ($fullname !== '') ? 'nickname' : 'fn nickname entity_nickname';
         $this->elementStart('a', array('href' => $profile,
                                        'class' => 'url '.$hasFN));
-        $this->raw($nickname);
+        $this->text($nickname);
         $this->elementEnd('a');
 
         if (!is_null($fullname)) {
             $this->elementStart('div', 'fn entity_fn');
-            $this->raw($fullname);
+            $this->text($fullname);
             $this->elementEnd('div');
         }
 
         if (!is_null($location)) {
             $this->elementStart('div', 'label entity_location');
-            $this->raw($location);
+            $this->text($location);
             $this->elementEnd('div');
         }
 
         if (!is_null($homepage)) {
             $this->elementStart('a', array('href' => $homepage,
                                            'class' => 'url entity_url'));
-            $this->raw($homepage);
+            $this->text($homepage);
             $this->elementEnd('a');
         }
 
         if (!is_null($note)) {
             $this->elementStart('div', 'note entity_note');
-            $this->raw($note);
+            $this->text($note);
             $this->elementEnd('div');
         }
         $this->elementEnd('div');
@@ -241,11 +241,16 @@ class OStatusSubAction extends Action
      */
     function pullRemoteProfile()
     {
-        $this->profile_uri = $this->trimmed('profile');
+        $validate = new Validate();
         try {
-            if (Validate::email($this->profile_uri)) {
+            $this->profile_uri = Discovery::normalize($this->trimmed('profile'));
+        } catch (Exception $e) {
+            $this->profile_uri = null;
+        }
+        try {
+            if (Discovery::isAcct($this->profile_uri) && $validate->email(mb_substr($this->profile_uri, 5))) {
                 $this->oprofile = Ostatus_profile::ensureWebfinger($this->profile_uri);
-            } else if (Validate::uri($this->profile_uri)) {
+            } else if ($validate->uri($this->profile_uri)) {
                 $this->oprofile = Ostatus_profile::ensureProfileURL($this->profile_uri);
             } else {
                 // TRANS: Error message in OStatus plugin. Do not translate the domain names example.com
@@ -280,6 +285,10 @@ class OStatusSubAction extends Action
             // TRANS: Error text.
             $this->error = _m("Sorry, we could not reach that feed. Please try that OStatus address again later.");
             common_debug('Not a recognized feed type.', __FILE__);
+        } catch (FeedSubNoHubException $e) {
+            // TRANS: Error text.
+            $this->error = _m("Sorry, that feed is not Pubsubhubub enabled.");
+            common_debug('No hub found.', __FILE__);
         } catch (Exception $e) {
             // Any new ones we forgot about
                 // TRANS: Error message in OStatus plugin. Do not translate the domain names example.com