summaryrefslogtreecommitdiff
path: root/includes/exception/HttpError.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2015-12-20 09:00:55 +0100
committerPierre Schmitz <pierre@archlinux.de>2015-12-20 09:00:55 +0100
commita2190ac74dd4d7080b12bab90e552d7aa81209ef (patch)
tree8b31f38de9882d18df54cf8d9e0de74167a094eb /includes/exception/HttpError.php
parent15e69f7b20b6596b9148030acce5b59993b95a45 (diff)
parent257401d8b2cf661adf36c84b0e3fd1cf85e33c22 (diff)
Merge branch 'mw-1.26'
Diffstat (limited to 'includes/exception/HttpError.php')
-rw-r--r--includes/exception/HttpError.php20
1 files changed, 9 insertions, 11 deletions
diff --git a/includes/exception/HttpError.php b/includes/exception/HttpError.php
index b81c5731..9211bf82 100644
--- a/includes/exception/HttpError.php
+++ b/includes/exception/HttpError.php
@@ -35,7 +35,7 @@ class HttpError extends MWException {
*
* @param int $httpCode HTTP status code to send to the client
* @param string|Message $content Content of the message
- * @param string|Message $header Content of the header (\<title\> and \<h1\>)
+ * @param string|Message|null $header Content of the header (\<title\> and \<h1\>)
*/
public function __construct( $httpCode, $content, $header = null ) {
parent::__construct( $content );
@@ -74,9 +74,7 @@ class HttpError extends MWException {
public function report() {
$this->doLog();
- $httpMessage = HttpStatus::getMessage( $this->httpCode );
-
- header( "Status: {$this->httpCode} {$httpMessage}", true, $this->httpCode );
+ HttpStatus::header( $this->httpCode );
header( 'Content-type: text/html; charset=utf-8' );
print $this->getHTML();
@@ -113,21 +111,21 @@ class HttpError extends MWException {
*/
public function getHTML() {
if ( $this->header === null ) {
- $header = HttpStatus::getMessage( $this->httpCode );
+ $titleHtml = htmlspecialchars( HttpStatus::getMessage( $this->httpCode ) );
} elseif ( $this->header instanceof Message ) {
- $header = $this->header->escaped();
+ $titleHtml = $this->header->escaped();
} else {
- $header = htmlspecialchars( $this->header );
+ $titleHtml = htmlspecialchars( $this->header );
}
if ( $this->content instanceof Message ) {
- $content = $this->content->escaped();
+ $contentHtml = $this->content->escaped();
} else {
- $content = htmlspecialchars( $this->content );
+ $contentHtml = nl2br( htmlspecialchars( $this->content ) );
}
return "<!DOCTYPE html>\n" .
- "<html><head><title>$header</title></head>\n" .
- "<body><h1>$header</h1><p>$content</p></body></html>\n";
+ "<html><head><title>$titleHtml</title></head>\n" .
+ "<body><h1>$titleHtml</h1><p>$contentHtml</p></body></html>\n";
}
}