X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fhtmloutputter.php;h=5e400379529b1c72e5b8c0631528d9ae78e3c3de;hb=5e7a7701b94ee63927750064a39b188d9e17164a;hp=dac3c621fc4fe82eecd2a8228748456e3816b99d;hpb=606d7d718510428fbe3c467c326bab017ea53423;p=quix0rs-gnu-social.git diff --git a/lib/htmloutputter.php b/lib/htmloutputter.php index dac3c621fc..5e40037952 100644 --- a/lib/htmloutputter.php +++ b/lib/htmloutputter.php @@ -28,11 +28,7 @@ * @link http://status.net/ */ -if (!defined('STATUSNET') && !defined('LACONICA')) { - exit(1); -} - -require_once INSTALLDIR.'/lib/xmloutputter.php'; +if (!defined('GNUSOCIAL')) { exit(1); } // Can include XHTML options but these are too fragile in practice. define('PAGE_TYPE_PREFS', 'text/html'); @@ -58,6 +54,9 @@ define('PAGE_TYPE_PREFS', 'text/html'); class HTMLOutputter extends XMLOutputter { + protected $DTD = array('doctype' => 'html', + 'spec' => '-//W3C//DTD XHTML 1.0 Strict//EN', + 'uri' => 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'); /** * Constructor * @@ -108,14 +107,20 @@ class HTMLOutputter extends XMLOutputter header('Content-Type: '.$type); + // Output anti-framing headers to prevent clickjacking (respected by newer + // browsers). + if (common_config('javascript', 'bustframes')) { + header('X-XSS-Protection: 1; mode=block'); // detect XSS Reflection attacks + header('X-Frame-Options: SAMEORIGIN'); // no rendering if origin mismatch + } + $this->extraHeaders(); if (preg_match("/.*\/.*xml/", $type)) { // Required for XML documents - $this->xw->startDocument('1.0', 'UTF-8'); + $this->startXML(); } - $this->xw->writeDTD('html', - '-//W3C//DTD XHTML 1.0 Strict//EN', - 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'); + + $this->writeDTD(); $language = $this->getLanguage(); @@ -131,6 +136,18 @@ class HTMLOutputter extends XMLOutputter } } + public function setDTD($doctype, $spec, $uri) + { + $this->DTD = array('doctype' => $doctype, 'spec' => $spec, 'uri' => $uri); + } + + protected function writeDTD() + { + $this->xw->writeDTD($this->DTD['doctype'], + $this->DTD['spec'], + $this->DTD['uri']); + } + function getLanguage() { // FIXME: correct language for interface @@ -166,12 +183,16 @@ class HTMLOutputter extends XMLOutputter * a cluster of elements, including a