X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FOutputPage.php;h=3e91fb346cf5511257552960e7a45b2f25f79461;hb=f0483b35c70c7c3ff9666202d9dfd650cc8337cb;hp=8a19c51f7a7b799b4aa13f55ca7766cdc9cd2b0b;hpb=0a6d507ed0871dba1f9baa4cc22dfcac34b047dd;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 8a19c51f7a..3e91fb346c 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -2187,7 +2187,7 @@ class OutputPage extends ContextSource { * Parse wikitext and return the HTML (internal implementation helper) * * @param string $text - * @param Title The title to use + * @param Title $title The title to use * @param bool $linestart Is this the start of a line? * @param bool $tidy Whether the output should be tidied * @param bool $interface Use interface language (instead of content language) while parsing @@ -2198,8 +2198,6 @@ class OutputPage extends ContextSource { * @return ParserOutput */ private function parseInternal( $text, $title, $linestart, $tidy, $interface, $language ) { - global $wgParser; - if ( is_null( $title ) ) { throw new MWException( 'Empty $mTitle in ' . __METHOD__ ); } @@ -2212,7 +2210,7 @@ class OutputPage extends ContextSource { $oldLang = $popts->setTargetLanguage( $language ); } - $parserOutput = $wgParser->getFreshParser()->parse( + $parserOutput = MediaWikiServices::getInstance()->getParser()->getFreshParser()->parse( $text, $title, $popts, $linestart, true, $this->mRevisionId ); @@ -2527,6 +2525,37 @@ class OutputPage extends ContextSource { return $config->get( 'OriginTrials' ); } + private function getReportTo() { + $config = $this->getConfig(); + + $expiry = $config->get( 'ReportToExpiry' ); + + if ( !$expiry ) { + return false; + } + + $endpoints = $config->get( 'ReportToEndpoints' ); + + if ( !$endpoints ) { + return false; + } + + $output = [ 'max_age' => $expiry, 'endpoints' => [] ]; + + foreach ( $endpoints as $endpoint ) { + $output['endpoints'][] = [ 'url' => $endpoint ]; + } + + return json_encode( $output, JSON_UNESCAPED_SLASHES ); + } + + private function getFeaturePolicyReportOnly() { + $config = $this->getConfig(); + + $features = $config->get( 'FeaturePolicyReportOnly' ); + return implode( ';', $features ); + } + /** * Send cache control HTTP headers */ @@ -2678,10 +2707,6 @@ class OutputPage extends ContextSource { $response->header( 'Content-language: ' . MediaWikiServices::getInstance()->getContentLanguage()->getHtmlCode() ); - if ( !$this->mArticleBodyOnly ) { - $sk = $this->getSkin(); - } - $linkHeader = $this->getLinkHeader(); if ( $linkHeader ) { $response->header( $linkHeader ); @@ -2698,6 +2723,16 @@ class OutputPage extends ContextSource { $response->header( "Origin-Trial: $originTrial", false ); } + $reportTo = $this->getReportTo(); + if ( $reportTo ) { + $response->header( "Report-To: $reportTo" ); + } + + $featurePolicyReportOnly = $this->getFeaturePolicyReportOnly(); + if ( $featurePolicyReportOnly ) { + $response->header( "Feature-Policy-Report-Only: $featurePolicyReportOnly" ); + } + ContentSecurityPolicy::sendHeaders( $this ); if ( $this->mArticleBodyOnly ) { @@ -3223,7 +3258,10 @@ class OutputPage extends ContextSource { // Use an IE conditional comment to serve the script only to old IE $pieces[] = '