From c397a2f89bf3c2c609852f5bfc618c1d0cb0b709 Mon Sep 17 00:00:00 2001 From: Friendika Date: Wed, 16 Feb 2011 20:25:10 -0800 Subject: [PATCH] properly handle error returns in post w/ajax --- mod/follow.php | 4 ++++ mod/item.php | 13 +++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/mod/follow.php b/mod/follow.php index 763ffb1b01..28441eae8f 100644 --- a/mod/follow.php +++ b/mod/follow.php @@ -117,6 +117,10 @@ function follow_post(&$a) { $author = $feed->get_author(); if($author) { $vcard['fn'] = unxmlify(trim($author->get_name())); + if(! $vcard['fn']) + $vcard['fn'] = trim(unxmlify($author->get_email())); + if(strpos($vcard['fn'],'@') !== false) + $vcard['fn'] = substr($vcard['fn'],0,strpos($vcard['fn'],'@')); $vcard['nick'] = strtolower(notags(unxmlify($vcard['fn']))); if(strpos($vcard['nick'],' ')) $vcard['nick'] = trim(substr($vcard['nick'],0,strpos($vcard['nick'],' '))); diff --git a/mod/item.php b/mod/item.php index 21dfb45607..cbdd11eb97 100644 --- a/mod/item.php +++ b/mod/item.php @@ -35,7 +35,9 @@ function item_post(&$a) { ); if(! count($r)) { notice( t('Unable to locate original post.') . EOL); - goaway($a->get_baseurl() . "/" . $_POST['return'] ); + if(x($_POST,'return')) + goaway($a->get_baseurl() . "/" . $_POST['return'] ); + killme(); } $parent_item = $r[0]; if($parent_item['contact-id'] && $uid) { @@ -53,7 +55,9 @@ function item_post(&$a) { if(! can_write_wall($a,$profile_uid)) { notice( t('Permission denied.') . EOL) ; - return; + if(x($_POST,'return')) + goaway($a->get_baseurl() . "/" . $_POST['return'] ); + killme(); } $user = null; @@ -92,8 +96,9 @@ function item_post(&$a) { if(! strlen($body)) { notice( t('Empty post discarded.') . EOL ); - goaway($a->get_baseurl() . "/" . $_POST['return'] ); - + if(x($_POST,'return')) + goaway($a->get_baseurl() . "/" . $_POST['return'] ); + killme(); } // get contact info for poster