Skip to content

Commit

Permalink
Revert "Bug 1893698 - Remove the cache-friendly redirect from / to /h…
Browse files Browse the repository at this point in the history
…ome that originally addressed a DoS from Firefox version 52"

This reverts commit d95c7d7.
  • Loading branch information
dklawren committed Apr 30, 2024
1 parent d95c7d7 commit 74c9480
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 16 deletions.
2 changes: 2 additions & 0 deletions Bugzilla/App.pm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use Bugzilla::Logging;
use Bugzilla::App::API;
use Bugzilla::App::BouncedEmails;
use Bugzilla::App::CGI;
use Bugzilla::App::Main;
use Bugzilla::App::OAuth2::Provider::Clients;
use Bugzilla::App::SES;
use Bugzilla::App::Static;
Expand Down Expand Up @@ -209,6 +210,7 @@ sub setup_routes {
Bugzilla::App::API->setup_routes($r);
Bugzilla::App::BouncedEmails->setup_routes($r);
Bugzilla::App::CGI->setup_routes($r);
Bugzilla::App::Main->setup_routes($r);
Bugzilla::App::OAuth2::Provider::Clients->setup_routes($r);
Bugzilla::App::SES->setup_routes($r);
Bugzilla::App::BMO::AntiSpam->setup_routes($r);
Expand Down
16 changes: 0 additions & 16 deletions Bugzilla/App/CGI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ sub setup_routes {
$class->load_one($name, $file);
$r->any("/$file")->to("CGI#$name");
}

$r->any('/')->to('CGI#index_cgi');
$r->any('/home')->to('CGI#index_cgi');

$r->any('/bug/<id:num>')->to('CGI#show_bug_cgi');
Expand All @@ -50,20 +48,6 @@ sub setup_routes {
$c->res->code(301);
$c->redirect_to(Bugzilla->localconfig->basepath . 'enter_bug.cgi');
});

$r->get('/testagent.cgi' => sub { shift->render(text => 'OK Mojolicious')});

$r->add_type('hex32' => qr/[[:xdigit:]]{32}/);
$r->post('/announcement/hide/<checksum:hex32>')->to('CGI#announcement_hide');
}

sub announcement_hide {
my ($self) = @_;
my $checksum = $self->param('checksum');
if ($checksum && $checksum =~ /^[[:xdigit:]]{32}$/) {
$self->session->{announcement_checksum} = $checksum;
}
$self->render(json => {});
}

sub load_one {
Expand Down
47 changes: 47 additions & 0 deletions Bugzilla/App/Main.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This Source Code Form is "Incompatible With Secondary Licenses", as
# defined by the Mozilla Public License, v. 2.0.

package Bugzilla::App::Main;
use Mojo::Base 'Mojolicious::Controller';

use Bugzilla::Error;
use Try::Tiny;
use Bugzilla::Constants;

sub setup_routes {
my ($class, $r) = @_;

$r->any('/')->to('Main#root');

$r->get('/testagent.cgi')->to('Main#testagent');

$r->add_type('hex32' => qr/[[:xdigit:]]{32}/);
$r->post('/announcement/hide/<checksum:hex32>')->to('Main#announcement_hide');
}

sub root {
my ($c) = @_;
$c->res->headers->cache_control('public, max-age=3600, immutable');
$c->stash('urlbase', Bugzilla->localconfig->urlbase);
$c->render(handler => 'bugzilla');
}

sub testagent {
my ($self) = @_;
$self->render(text => "OK Mojolicious");
}

sub announcement_hide {
my ($self) = @_;
my $checksum = $self->param('checksum');
if ($checksum && $checksum =~ /^[[:xdigit:]]{32}$/) {
$self->session->{announcement_checksum} = $checksum;
}
$self->render(json => {});
}

1;
2 changes: 2 additions & 0 deletions template/en/default/main/root.html.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[% SET home_url = c.stash.urlbase _ 'home' %]
[% PROCESS index.html.tmpl meta_refresh="0;URL='$home_url'" %]

0 comments on commit 74c9480

Please sign in to comment.