git.gnu.io has moved to IP address 209.51.188.249 -- please double check where you are logging in.

Commit 5067939e authored by Evan Prodromou's avatar Evan Prodromou

Try to do intelligent redirect codes

After fixing the redirect code output, there are a lot of weirdnesses
with e.g. form handling. Try to add explicit redirect codes where
needed -- principly when handling a POST.
parent e3d5f965
......@@ -93,7 +93,8 @@ class BlockAction extends Action
if ($this->arg('no')) {
$cur = common_current_user();
$other = Profile::staticGet('id', $this->arg('blockto'));
common_redirect(common_local_url('showstream', array('nickname' => $other->nickname)));
common_redirect(common_local_url('showstream', array('nickname' => $other->nickname)),
303);
} elseif ($this->arg('yes')) {
$this->blockProfile();
} elseif ($this->arg('blockto')) {
......@@ -102,7 +103,6 @@ class BlockAction extends Action
}
}
function showContent() {
$this->areYouSureForm();
}
......@@ -110,7 +110,7 @@ class BlockAction extends Action
function title() {
return _('Block user');
}
function showNoticeForm() {
// nop
}
......@@ -178,10 +178,11 @@ class BlockAction extends Action
}
if ($action) {
common_redirect(common_local_url($action, $args));
common_redirect(common_local_url($action, $args), 303);
} else {
common_redirect(common_local_url('subscriptions',
array('nickname' => $cur->nickname)));
array('nickname' => $cur->nickname)),
303);
}
}
}
......
......@@ -141,6 +141,6 @@ class DeletenoticeAction extends DeleteAction
$url = common_local_url('public');
}
common_redirect($url);
common_redirect($url, 303);
}
}
......@@ -49,7 +49,7 @@ class DisfavorAction extends Action
{
/**
* Class handler.
*
*
* @param array $args query arguments
*
* @return void
......@@ -100,7 +100,8 @@ class DisfavorAction extends Action
$this->elementEnd('html');
} else {
common_redirect(common_local_url('showfavorites',
array('nickname' => $user->nickname)));
array('nickname' => $user->nickname)),
303);
}
}
}
......
......@@ -166,7 +166,6 @@ class EditgroupAction extends Action
return;
}
$nickname = common_canonical_nickname($this->trimmed('nickname'));
$fullname = $this->trimmed('fullname');
$homepage = $this->trimmed('homepage');
......@@ -221,7 +220,7 @@ class EditgroupAction extends Action
if ($this->group->nickname != $orig->nickname) {
common_redirect(common_local_url('editgroup',
array('nickname' => $nickname)),
307);
303);
} else {
$this->showForm(_('Options saved.'));
}
......
......@@ -52,7 +52,7 @@ class FavorAction extends Action
{
/**
* Class handler.
*
*
* @param array $args query arguments
*
* @return void
......@@ -100,13 +100,14 @@ class FavorAction extends Action
$this->elementEnd('html');
} else {
common_redirect(common_local_url('showfavorites',
array('nickname' => $user->nickname)));
array('nickname' => $user->nickname)),
303);
}
}
/**
* Notifies a user when his notice is favorited.
*
*
* @param class $notice favorited notice
* @param class $user user declaring a favorite
*
......
......@@ -139,7 +139,7 @@ class FinishaddopenidAction extends Action
oid_set_last($display);
common_redirect(common_local_url('openidsettings'));
common_redirect(common_local_url('openidsettings'), 303);
}
}
......
......@@ -271,7 +271,8 @@ class FinishopenidloginAction extends Action
common_rememberme($user);
}
unset($_SESSION['openid_rememberme']);
common_redirect(common_local_url('showstream', array('nickname' => $user->nickname)));
common_redirect(common_local_url('showstream', array('nickname' => $user->nickname)),
303);
}
function connectUser()
......@@ -324,7 +325,7 @@ class FinishopenidloginAction extends Action
array('nickname' =>
$nickname));
}
common_redirect($url);
common_redirect($url, 303);
}
function bestNewNickname($display, $sreg)
......
......@@ -230,7 +230,8 @@ class FinishremotesubscribeAction extends Action
# show up close to the top of the page
common_redirect(common_local_url('subscribers', array('nickname' =>
$user->nickname)));
$user->nickname)),
303);
}
function add_avatar($profile, $url)
......
......@@ -143,7 +143,8 @@ class JoingroupAction extends Action
$this->elementEnd('html');
} else {
common_redirect(common_local_url('groupmembers', array('nickname' =>
$this->group->nickname)));
$this->group->nickname)),
303);
}
}
}
\ No newline at end of file
......@@ -147,7 +147,8 @@ class LeavegroupAction extends Action
$this->elementEnd('html');
} else {
common_redirect(common_local_url('groupmembers', array('nickname' =>
$this->group->nickname)));
$this->group->nickname)),
303);
}
}
}
......@@ -138,7 +138,7 @@ class LoginAction extends Action
$nickname));
}
common_redirect($url);
common_redirect($url, 303);
}
/**
......
......@@ -46,10 +46,10 @@ require_once INSTALLDIR.'/lib/openid.php';
*/
class LogoutAction extends Action
{
/**
* This is read only.
*
*
* @return boolean true
*/
function isReadOnly()
......@@ -59,7 +59,7 @@ class LogoutAction extends Action
/**
* Class handler.
*
*
* @param array $args array of arguments
*
* @return nothing
......@@ -73,7 +73,7 @@ class LogoutAction extends Action
common_set_user(null);
common_real_login(false); // not logged in
common_forgetme(); // don't log back in!
common_redirect(common_local_url('public'));
common_redirect(common_local_url('public'), 303);
}
}
}
......@@ -193,7 +193,7 @@ class NewgroupAction extends Action
$group->query('COMMIT');
common_redirect($group->homeUrl(), 307);
common_redirect($group->homeUrl(), 303);
}
function nicknameExists($nickname)
......
......@@ -50,7 +50,7 @@ class NudgeAction extends Action
{
/**
* Class handler.
*
*
* @param array $args array of arguments
*
* @return nothing
......@@ -75,7 +75,7 @@ class NudgeAction extends Action
// CSRF protection
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
$this->clientError(_('There was a problem with your session token. Try again, please.'));
return;
......@@ -100,7 +100,8 @@ class NudgeAction extends Action
} else {
// display a confirmation to the user
common_redirect(common_local_url('showstream',
array('nickname' => $other->nickname)));
array('nickname' => $other->nickname)),
303);
}
}
......
......@@ -99,7 +99,7 @@ class RemotesubscribeAction extends Action
$this->elementStart('fieldset');
$this->element('legend', 'Subscribe to a remote user');
$this->hidden('token', common_session_token());
$this->elementStart('ul', 'form_data');
$this->elementStart('li');
$this->input('nickname', _('User nickname'), $this->nickname,
......@@ -407,7 +407,7 @@ class RemotesubscribeAction extends Action
# Redirect to authorization service
common_redirect($req->to_url());
common_redirect($req->to_url(), 303);
return;
}
}
......@@ -488,7 +488,8 @@ class SmssettingsAction extends ConnectSettingsAction
}
common_redirect(common_local_url('confirmaddress',
array('code' => $code)));
array('code' => $code)),
303);
}
/**
......
......@@ -85,7 +85,8 @@ class SubeditAction extends Action
}
common_redirect(common_local_url('subscriptions',
array('nickname' => $cur->nickname)));
array('nickname' => $cur->nickname)),
303);
}
}
}
......@@ -75,7 +75,8 @@ class SubscribeAction extends Action
$this->elementEnd('html');
} else {
common_redirect(common_local_url('subscriptions', array('nickname' =>
$user->nickname)));
$user->nickname)),
303);
}
}
}
......@@ -33,7 +33,9 @@ class TagAction extends Action
}
if ($this->tag != $taginput) {
common_redirect(common_local_url('tag', array('tag' => $this->tag)));
common_redirect(common_local_url('tag', array('tag' => $this->tag)),
301);
return false;
}
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
......
......@@ -221,7 +221,8 @@ class TagotherAction extends Action
$this->elementEnd('html');
} else {
common_redirect(common_local_url($action, array('nickname' =>
$user->nickname)));
$user->nickname)),
303);
}
}
......
......@@ -116,10 +116,11 @@ class UnblockAction extends Action
}
}
if ($action) {
common_redirect(common_local_url($action, $args));
common_redirect(common_local_url($action, $args), 303);
} else {
common_redirect(common_local_url('subscriptions',
array('nickname' => $cur->nickname)));
array('nickname' => $cur->nickname)),
303);
}
}
}
......
......@@ -77,7 +77,8 @@ class UnsubscribeAction extends Action
$this->elementEnd('html');
} else {
common_redirect(common_local_url('subscriptions', array('nickname' =>
$user->nickname)));
$user->nickname)),
303);
}
}
}
......@@ -171,7 +171,7 @@ function oid_authenticate($openid_url, $returnto, $immediate=false)
} else if (Auth_OpenID::isFailure($redirect_url)) {
return sprintf(_('Could not redirect to server: %s'), $redirect_url->message);
} else {
common_redirect($redirect_url);
common_redirect($redirect_url, 303);
}
} else {
// Generate form markup and render it.
......
......@@ -78,9 +78,9 @@ class SettingsAction extends Action
common_set_returnto($this->selfUrl());
$user = common_current_user();
if ($user->hasOpenID()) {
common_redirect(common_local_url('openidlogin'));
common_redirect(common_local_url('openidlogin'), 303);
} else {
common_redirect(common_local_url('login'));
common_redirect(common_local_url('login'), 303);
}
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$this->handlePost();
......
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