summaryrefslogtreecommitdiff
path: root/lib/VNDB/Handler/Misc.pm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2015-07-19 01:32:21 +0200
committerYorhel <git@yorhel.nl>2015-07-19 01:32:21 +0200
commitd8c2d33dc57e1d26d6fe5d63fd08872effe0c0fa (patch)
tree78433f867f72a6b5d165be8e33826dc7e6251d2b /lib/VNDB/Handler/Misc.pm
parent9c7776828a722edcd7bb5eb0ebf61e4a08d7ecd2 (diff)
Remove reliance on Referer header for language switching
First step in removing the use of the Referer header for redirects. The Referer header is ugly and not always reliable, it's better to encode the required information in the URL.
Diffstat (limited to 'lib/VNDB/Handler/Misc.pm')
-rw-r--r--lib/VNDB/Handler/Misc.pm18
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/VNDB/Handler/Misc.pm b/lib/VNDB/Handler/Misc.pm
index fc82c4f0..d190291a 100644
--- a/lib/VNDB/Handler/Misc.pm
+++ b/lib/VNDB/Handler/Misc.pm
@@ -350,19 +350,19 @@ sub docpage {
sub setlang {
my $self = shift;
- my $lang = $self->formValidate({get => 'lang', required => 1, enum => [ VNDB::L10N::languages ]});
- return $self->resNotFound if $lang->{_err};
- $lang = $lang->{lang};
+ my $frm = $self->formValidate(
+ {get => 'lang', required => 1, enum => [ VNDB::L10N::languages ]},
+ {get => 'ref', required => 0, default => '/'}
+ );
+ return $self->resNotFound if $frm->{_err};
my $browser = VNDB::L10N->get_handle()->language_tag();
- my $b = $self->reqBaseURI();
- (my $ref = $self->reqHeader('Referer')||'/') =~ s/^\Q$b//;
- $self->resRedirect($ref, 'post');
- if($lang ne $self->{l10n}->language_tag()) {
+ $self->resRedirect($frm->{ref}, 'post');
+ if($frm->{lang} ne $self->{l10n}->language_tag()) {
$self->authInfo->{id}
- ? $self->authPref(l10n => $lang eq $browser ? undef : $lang)
- : $self->resCookie(l10n => $lang eq $browser ? undef : $lang, expires => time()+31536000);
+ ? $self->authPref(l10n => $frm->{lang} eq $browser ? undef : $frm->{lang})
+ : $self->resCookie(l10n => $frm->{lang} eq $browser ? undef : $frm->{lang}, expires => time()+31536000);
}
}