summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladimir Panteleev <github.private@thecybershadow.net>2018-03-18 05:59:38 +0100
committerDylan William Hardison <dylan@hardison.net>2018-03-18 05:59:38 +0100
commitfec3b27bc797824496201e61a0b554331c2cedd5 (patch)
tree2f212325b04d301c438838a93cf0223e8b02398f
parentb60e501b05c49eb8187a2ce755d4263f132ecdb8 (diff)
downloadbugzilla-fec3b27bc797824496201e61a0b554331c2cedd5.tar.gz
bugzilla-fec3b27bc797824496201e61a0b554331c2cedd5.tar.xz
Bug 1446236 - Generate static error pages
-rw-r--r--Bugzilla/Install/Filesystem.pm78
-rw-r--r--errors/401.html40
-rw-r--r--errors/403.html37
-rw-r--r--errors/404.html37
-rw-r--r--errors/500.html37
5 files changed, 78 insertions, 151 deletions
diff --git a/Bugzilla/Install/Filesystem.pm b/Bugzilla/Install/Filesystem.pm
index 2f4beee4d..2333f18e4 100644
--- a/Bugzilla/Install/Filesystem.pm
+++ b/Bugzilla/Install/Filesystem.pm
@@ -115,6 +115,51 @@ sub HTTPD_ENV_CONF {
return join( "\n", map { "PerlPassEnv " . $_ } @env ) . "\n";
}
+sub _error_page {
+ my ($code, $title, $description) = @_;
+ my $host = Bugzilla->urlbase->host;
+
+ return <<EOT;
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <title>$title</title>
+ <style>
+ body {
+ margin: 1em 2em;
+ background-color: #455372;
+ color: #ddd;
+ font-family: sans-serif;
+ }
+ h1, h3 {
+ color: #fff;
+ }
+ a {
+ color: #fff;
+ text-decoration: none;
+ }
+ #buggie {
+ float: left;
+ }
+ #content {
+ margin-left: 100px;
+ padding-top: 20px;
+ }
+ </style>
+ </head>
+ <body>
+ <img src="/images/buggie.png" id="buggie" alt="buggie" width="78" height="215">
+ <div id="content">
+ <h1>$title</h1>
+ <p>$description</p>
+ <h3>Error $code</h3>
+ <p><a href="/">$host</a></p>
+ </div>
+ </body>
+</html>
+EOT
+}
+
###############
# Permissions #
###############
@@ -429,6 +474,39 @@ sub FILESYSTEM {
contents => \&HTTPD_ENV_CONF },
);
+ # Create static error pages.
+ $create_files{"errors/401.html"} = {
+ perms => CGI_READ,
+ overwrite => 1,
+ contents => _error_page(
+ 401, 'Authentication Required',
+ "This server could not verify that you are authorized to access
+ that url. you either supplied the wrong credentials (e.g., bad
+ password), or your browser doesn't understand how to supply the
+ credentials required.")
+ };
+ $create_files{"errors/403.html"} = {
+ perms => CGI_READ,
+ overwrite => 1,
+ contents => _error_page(
+ 403, 'Access Denied',
+ "Access to the requested resource has been denied.")
+ };
+ $create_files{"errors/404.html"} = {
+ perms => CGI_READ,
+ overwrite => 1,
+ contents => _error_page(
+ 404, 'Object Not Found',
+ "The requested URL was not found on this server.")
+ };
+ $create_files{"errors/500.html"} = {
+ perms => CGI_READ,
+ overwrite => 1,
+ contents => _error_page(
+ 500, 'Internal Server Error',
+ "The server encountered an internal error and was unable to complete your request.")
+ };
+
# Because checksetup controls the creation of index.html separately
# from all other files, it gets its very own hash.
my %index_html = (
diff --git a/errors/401.html b/errors/401.html
deleted file mode 100644
index 8242b549f..000000000
--- a/errors/401.html
+++ /dev/null
@@ -1,40 +0,0 @@
-<!DOCTYPE HTML>
-<html>
- <head>
- <title>Access Denied</title>
- <style>
- body {
- margin: 1em 2em;
- background-color: #455372;
- color: #ddd;
- font-family: sans-serif;
- }
- h1, h3 {
- color: #fff;
- }
- a {
- color: #fff;
- text-decoration: none;
- }
- #buggie {
- float: left;
- }
- #content {
- margin-left: 100px;
- padding-top: 20px;
- }
- </style>
- </head>
- <body>
- <img src="/images/buggie.png" id="buggie" alt="buggie" width="78" height="215">
- <div id="content">
- <h1>Authentication Required</h1>
- <p>This server could not verify that you are authorized to access
- that url. you either supplied the wrong credentials (e.g., bad
- password), or your browser doesn't understand how to supply the
- credentials required.</p>
- <h3>Error 401</h3>
- <p><a href="/">bugzilla.mozilla.org</a></p>
- </div>
- </body>
-</html>
diff --git a/errors/403.html b/errors/403.html
deleted file mode 100644
index e2faf8522..000000000
--- a/errors/403.html
+++ /dev/null
@@ -1,37 +0,0 @@
-<!DOCTYPE HTML>
-<html>
- <head>
- <title>Access Denied</title>
- <style>
- body {
- margin: 1em 2em;
- background-color: #455372;
- color: #ddd;
- font-family: sans-serif;
- }
- h1, h3 {
- color: #fff;
- }
- a {
- color: #fff;
- text-decoration: none;
- }
- #buggie {
- float: left;
- }
- #content {
- margin-left: 100px;
- padding-top: 20px;
- }
- </style>
- </head>
- <body>
- <img src="/images/buggie.png" id="buggie" alt="buggie" width="78" height="215">
- <div id="content">
- <h1>Access Denied</h1>
- <p>Access to the requested resource has been denied.</p>
- <h3>Error 403</h3>
- <p><a href="/">bugzilla.mozilla.org</a></p>
- </div>
- </body>
-</html>
diff --git a/errors/404.html b/errors/404.html
deleted file mode 100644
index 3b476471c..000000000
--- a/errors/404.html
+++ /dev/null
@@ -1,37 +0,0 @@
-<!DOCTYPE HTML>
-<html>
- <head>
- <title>Object Not Found</title>
- <style>
- body {
- margin: 1em 2em;
- background-color: #455372;
- color: #ddd;
- font-family: sans-serif;
- }
- h1, h3 {
- color: #fff;
- }
- a {
- color: #fff;
- text-decoration: none;
- }
- #buggie {
- float: left;
- }
- #content {
- margin-left: 100px;
- padding-top: 20px;
- }
- </style>
- </head>
- <body>
- <img src="/images/buggie.png" id="buggie" alt="buggie" width="78" height="215">
- <div id="content">
- <h1>Object Not Found</h1>
- <p>The requested URL was not found on this server.</p>
- <h3>Error 404</h3>
- <p><a href="/">bugzilla.mozilla.org</a></p>
- </div>
- </body>
-</html>
diff --git a/errors/500.html b/errors/500.html
deleted file mode 100644
index e0657001d..000000000
--- a/errors/500.html
+++ /dev/null
@@ -1,37 +0,0 @@
-<!DOCTYPE HTML>
-<html>
- <head>
- <title>Internal Server Error</title>
- <style>
- body {
- margin: 1em 2em;
- background-color: #455372;
- color: #ddd;
- font-family: sans-serif;
- }
- h1, h3 {
- color: #fff;
- }
- a {
- color: #fff;
- text-decoration: none;
- }
- #buggie {
- float: left;
- }
- #content {
- margin-left: 100px;
- padding-top: 20px;
- }
- </style>
- </head>
- <body>
- <img src="/images/buggie.png" id="buggie" alt="buggie" width="78" height="215">
- <div id="content">
- <h1>Internal Server Error</h1>
- <p>The server encountered an internal error and was unable to complete your request.</p>
- <h3>Error 500</h3>
- <p><a href="/">bugzilla.mozilla.org</a></p>
- </div>
- </body>
-</html>