[Jifty-commit] r3345 - in jifty/trunk: lib/Jifty
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Sun Jun 3 21:14:42 EDT 2007
Author: jesse
Date: Sun Jun 3 21:14:41 2007
New Revision: 3345
Modified:
jifty/trunk/ (props changed)
jifty/trunk/lib/Jifty/Web.pm
Log:
r57927 at pinglin: jesse | 2007-06-03 21:13:23 -0400
* More bulletproofing for redirects related to single page apps
Modified: jifty/trunk/lib/Jifty/Web.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web.pm (original)
+++ jifty/trunk/lib/Jifty/Web.pm Sun Jun 3 21:14:41 2007
@@ -613,9 +613,19 @@
sub redirect {
my $self = shift;
- my $page = shift || $self->next_page || $self->request->path;
- $page = Jifty::Web::Form::Clickable->new( url => $page )
- unless ref $page and $page->isa("Jifty::Web::Form::Clickable");
+ my $redir_to = shift || $self->next_page || $self->request->path;
+
+
+ my $page;
+
+ if ( ref $redir_to and $redir_to->isa("Jifty::Web::Form::Clickable")) {
+ $page = $redir_to;
+ } else {
+
+ $page = Jifty::Web::Form::Clickable->new();
+ #We set this after creation to ensure that plugins that massage clickables don't impact us
+ $page->url($redir_to );
+ }
carp "Don't include GET parameters in the redirect URL -- use a Jifty::Web::Form::Clickable instead. See L<Jifty::Web/redirect>" if $page->url =~ /\?/;
@@ -626,6 +636,10 @@
# To submit a Jifty::Action::Redirect, we don't need to serialize a continuation,
# unlike any other kind of actions.
+
+
+ my $redirect_to_url = '' ;
+
if ( (grep { not $_->action_class->isa('Jifty::Action::Redirect') }
values %{ { $self->response->results } })
or $self->request->state_variables
@@ -662,11 +676,11 @@
response => $self->response,
parent => $self->request->continuation,
);
- $page = $page->url."?J:RETURN=" . $cont->id;
+ $redirect_to_url = $page->url."?J:RETURN=" . $cont->id;
} else {
- $page = $page->complete_url;
+ $redirect_to_url = $page->complete_url;
}
- $self->_redirect($page);
+ $self->_redirect($redirect_to_url);
}
sub _redirect {
@@ -674,6 +688,7 @@
my ($page) = @_;
+
if ($self->current_region) {
# If we're within a region stack, we don't really want to redirect. We want to redispatch.
$self->replace_current_region($page);
@@ -694,7 +709,7 @@
my $apache = Jifty->handler->apache;
- $self->log->debug("Redirecting to $page");
+ $self->log->debug("Execing redirect to $page");
# Headers..
$apache->header_out( Location => $page );
$apache->header_out( Status => 302 );
More information about the Jifty-commit
mailing list